Example #1
0
// Make a move on cell (x, y) according to the SGF move execution rules,
// and update the current board info and history (but not the GUI)
void SimpleGoPanel::MakeMoveSGF(int x, int y)
{	if(x<=0 || y<=0 || x>boardsize || y>boardsize)
		return;
	
	board[x][y] = curmove%2+1;
	int colour = board[x][y];
	int oppcolour = OPP(colour);

	if(board[x-1][y]==oppcolour && !HasLiberties(board, x-1, y))
		RemoveGroup(board, x-1, y);
	if(board[x+1][y]==oppcolour && !HasLiberties(board, x+1, y))
		RemoveGroup(board, x+1, y);
	if(board[x][y+1]==oppcolour && !HasLiberties(board, x, y+1))
		RemoveGroup(board, x, y+1);
	if(board[x][y-1]==oppcolour && !HasLiberties(board, x, y-1))
		RemoveGroup(board, x, y-1);
	if(!HasLiberties(board, x, y))
	{	RemoveGroup(board, x, y);
		frame->madesuicide = true;
	}
	
	curmove++;
	history = (char(*)[21][21])realloc(history, (curmove+1)*BOARDMEMORYLEN);
	memcpy(history[curmove], board, BOARDMEMORYLEN);
	movelist = (pos*)realloc(movelist, curmove*sizeof(pos));
	movelist[curmove-1].x = x;
	movelist[curmove-1].y = y;
	totmove = curmove;
}
Example #2
0
// Determine if a move at cell (x, y) with given colour is valid on the given board
bool SimpleGoPanel::ValidMove(char board[21][21], int x, int y, int colour)
{	if(board[x][y]!=EMPTY)
		return false;
		
	board[x][y] = colour;
	int oppcolour = OPP(colour);

	if(board[x-1][y]==oppcolour && !HasLiberties(board, x-1, y))
		RemoveGroup(board, x-1, y);
	if(board[x+1][y]==oppcolour && !HasLiberties(board, x+1, y))
		RemoveGroup(board, x+1, y);
	if(board[x][y+1]==oppcolour && !HasLiberties(board, x, y+1))
		RemoveGroup(board, x, y+1);
	if(board[x][y-1]==oppcolour && !HasLiberties(board, x, y-1))
		RemoveGroup(board, x, y-1);
	if(!frame->suicide && !HasLiberties(board, x, y))
		return false;
	else if(!HasLiberties(board, x, y))
		RemoveGroup(board, x, y);
		
	bool dupe = false;
	for(int i=0; i<=curmove; i++)
		if(memcmp(board, history[i], BOARDMEMORYLEN)==0)
			dupe = true;
	
	return !dupe;
}
Example #3
0
// Remove the group on the given board containing cell (x, y)
void SimpleGoPanel::RemoveGroup(char board[21][21], int x, int y)
{	int colour = board[x][y];
	board[x][y] = EMPTY;
	if(board[x-1][y]==colour)
		RemoveGroup(board, x-1, y);
	if(board[x+1][y]==colour)
		RemoveGroup(board, x+1, y);
	if(board[x][y-1]==colour)
		RemoveGroup(board, x, y-1);
	if(board[x][y+1]==colour)
		RemoveGroup(board, x, y+1);
}
 i32 IResourceManager::DestroyGroup( const GroupHandle& Handle )
 {
     GroupPtr pGroup = RemoveGroup( Handle );
     if( !pGroup )
         return XST_FAIL;
     return XST_OK;
 }
Example #5
0
// used to recursively select groups from eligible groups
bool BattleGroundQueue::SelectionPool::Build(uint32 MinPlayers, uint32 MaxPlayers, EligibleGroups::iterator startitr)
{
    // start from the specified start iterator
    for(EligibleGroups::iterator itr1 = startitr; itr1 != m_CurrEligGroups->end(); ++itr1)
    {
        // if it fits in, select it
        if(GetPlayerCount() + (*itr1)->Players.size() <= MaxPlayers)
        {
            EligibleGroups::iterator next = itr1;
            ++next;
            AddGroup((*itr1));
            if(GetPlayerCount() >= MinPlayers)
            {
                // enough players are selected
                return true;
            }
            // try building from the rest of the elig. groups
            // if that succeeds, return true
            if(Build(MinPlayers,MaxPlayers,next))
                return true;
            // the rest didn't succeed, so this group cannot be included
            RemoveGroup((*itr1));
        }
    }
    // build didn't succeed
    return false;
}
Example #6
0
int32_t ScanGroups(void)
{
    CACHE1D_FIND_REC *srch;
    struct grpcache *fg, *fgg;

    initprintf("Searching for game data...\n");

    LoadGameList();
    LoadGroupsCache();

    srch = klistpath("/", "*.grp", CACHE1D_FIND_FILE);
    ProcessGroups(srch);
    klistfree(srch);

    srch = klistpath("/", "*.ssi", CACHE1D_FIND_FILE);
    ProcessGroups(srch);
    klistfree(srch);

    FreeGroupsCache();

    for (grpfile_t *grp = foundgrps; grp; grp=grp->next)
    {
        if (grp->type->dependency)
        {
            if (FindGroup(grp->type->dependency) == NULL) // couldn't find dependency
            {
                //initprintf("removing %s\n", grp->name);
                RemoveGroup(grp);
                grp = foundgrps;
                // start from the beginning so we can remove anything that depended on this grp
                continue;
            }
        }
    }

    if (usedgrpcache)
    {
        int32_t i = 0;
        FILE *fp;
        fp = fopen(GRPCACHEFILE, "wt");
        if (fp)
        {
            for (fg = usedgrpcache; fg; fg=fgg)
            {
                fgg = fg->next;
                fprintf(fp, "\"%s\" %d %d %d\n", fg->name, fg->size, fg->mtime, fg->crcval);
                Bfree(fg);
                i++;
            }
            fclose(fp);
        }
//        initprintf("Found %d recognized GRP %s.\n",i,i>1?"files":"file");

        return 0;
    }

    initprintf("Found no recognized game data!\n");

    return 0;
}
Example #7
0
void RemoveGroup(int32_t crcval)
{
    struct grpfile *grp;

    for (grp = foundgrps; grp; grp=grp->next)
    {
        if (grp->crcval == crcval)
        {
            if (grp == foundgrps)
                foundgrps = grp->next;
            else
            {
                struct grpfile *fg;

                for (fg = foundgrps; fg; fg=fg->next)
                {
                    if (fg->next == grp)
                    {
                        fg->next = grp->next;
                        break;
                    }
                }
            }

            Bfree((char *)grp->name);
            Bfree(grp);

            RemoveGroup(crcval);

            break;
        }
    }
}
//=============================================================================
void CPdpManager::SetGroupName(unsigned int idx, const std::string& newGroupName)
{
	assert((idx >= 0) && (idx < m_GroupList.size()));
	
	if (newGroupName == "")
		RemoveGroup(idx);
	else
		m_GroupList[idx] = newGroupName;
}
//************************************************************************
// removes a contact from the list
//************************************************************************
void CContactList::RemoveContact(HANDLE hContact) {
	CListContainer<CContactListEntry*,CContactListGroup*> *pGroup = NULL;
	
	///tstring strGroup = GetContactGroupPath(hContact);

	CListEntry<CContactListEntry*,CContactListGroup*> *pContactEntry = FindContact(hContact);
	if(!pContactEntry) {
		return;
	}

	if( !CConfig::GetBoolSetting(CLIST_USEGROUPS)){
		if(pContactEntry->GetType() == ITEM)
			RemoveItem(((CListItem<CContactListEntry*,CContactListGroup*>*)pContactEntry)->GetItemData());
		else
			RemoveGroup(((CListContainer<CContactListEntry*,CContactListGroup*>*)pContactEntry)->GetGroupData());
	} else {
		pGroup = (CListContainer<CContactListEntry*,CContactListGroup*>*)pContactEntry->GetParent();
		ASSERT(pGroup != NULL);
		
		CContactListEntry *pEntry = GetContactData(pContactEntry);
		if(!pEntry) {
			return;
		}
		// Update the contacts group if it has one
		if(pGroup->GetType() != ROOT)
		{
			if(!CAppletManager::IsSubContact(hContact) && pEntry->iStatus != ID_STATUS_OFFLINE)
				ChangeGroupObjectCounters(pGroup->GetGroupData()->strPath,0,-1);
			
			if(!CAppletManager::IsSubContact(hContact) && pEntry->iMessages > 0)
				ChangeGroupObjectCounters(pGroup->GetGroupData()->strPath,0,0,-pEntry->iMessages);
		}

		if(pContactEntry->GetType() == ITEM)
			pGroup->RemoveItem(((CListItem<CContactListEntry*,CContactListGroup*>*)pContactEntry)->GetItemData());
		else {
			pGroup->RemoveGroup(((CListContainer<CContactListEntry*,CContactListGroup*>*)pContactEntry)->GetGroupData());
			// Reenumerate all subcontacts (maybe MetaContacts was disabled
			int numContacts = CallService(MS_MC_GETNUMCONTACTS,(WPARAM)hContact,0);
			HANDLE hSubContact = NULL;
			for(int i=0;i<numContacts;i++) {
				hSubContact = (HANDLE *) CallService(MS_MC_GETSUBCONTACT,(WPARAM)hContact, (LPARAM)i);
				if(!FindContact(hSubContact)) {
					AddContact(hSubContact);
				}
			}
		}

		CListContainer<CContactListEntry*,CContactListGroup*> *pParent = (CListContainer<CContactListEntry*,CContactListGroup*>*)pGroup->GetParent();
		while(pParent != NULL && pGroup->IsEmpty() && !pGroup->GetGroupData()->hMetaContact)
		{
			pParent->RemoveGroup(pGroup->GetGroupData());
			pGroup = pParent;
			pParent = (CListContainer<CContactListEntry*,CContactListGroup*>*)pGroup->GetParent();
		}
	}
}
//------------------------------------------------------------------------
//! Removes the group and all the rows part of the group
//!
//! @param nGroupId ID of the group
//------------------------------------------------------------------------
void CGridListCtrlGroups::DeleteEntireGroup(int nGroupId)
{
	for (int nRow=0; nRow<GetItemCount(); ++nRow)
	{
		if (GetRowGroupId(nRow) == nGroupId)
		{
			DeleteItem(nRow);
			nRow--;
		}
	}
	RemoveGroup(nGroupId);
}
Example #11
0
// **************************************************************************
// RemoveAllGroups ()
//
// Description:
//	Remove all OPC Groups from OPC server, and delete associated CKGroup
//  objects if asked.
//
// Parameters:
//  bool		bDelete		Delete group objects after removing.  true by 
//							 default.
//
// Returns:
//  void
// **************************************************************************
void CKServer::RemoveAllGroups (bool bDelete /* = true */)
	{
	// Start with the head of linked list and work our way up chain:
	CKGroup *pGroup = m_pGroupHead;

	// Remove OPC Groups and delete assoicated CKGroup objects:
	if (bDelete)
		{
		// Work our way up linked list.  pGroup will be NULL when we reach
		// end, and we will then break out of loop.
		while (pGroup)
			{
			// Get the group's next item before we delete group.  The
			// next item will be the new head of linked list.
			m_pGroupHead = pGroup->GetNext ();

			// Remove and delete:
			RemoveGroup (pGroup, bDelete);

			// Next group to processes is the new head of the list:
			pGroup = m_pGroupHead;
			}
		}

	// Just remove the OPC Groups:
	else
		{
		// Work our way up linked list.  pGroup will be NULL when we reach
		// end, and we will then break out of loop.
		while (pGroup)
			{					
			// Remove the group:
			RemoveGroup (pGroup, bDelete);

			// Process next group in list:
			pGroup = pGroup->GetNext ();
			}
		}
	}
void CPdpManager::RemoveGroup(const std::string& group )
{
	dprintf("Removing Group: %s\n", group.c_str());
	int GroupInx = -1;
	for (int i = 0; i != m_GroupList.size(); i++)
	{
		if (m_GroupList[i] == group)
		{
			GroupInx = i;
			break;
		}
	}

	RemoveGroup(GroupInx);
}
//*****************************************************************************************
BOOL CBCGPToolBoxEx::RemoveToolsPage (int nPage)
{
	ASSERT_VALID (this);

	CBCGPToolBoxPage* pPage = GetPage (nPage);
	if (pPage == NULL)
	{
		return FALSE;
	}

	ASSERT_VALID (pPage);
	pPage->DestroyWindow ();

	RemoveGroup (nPage);
	return TRUE;
}
Example #14
0
BOOL CCfgFile::CopyGroup( LPCTSTR pGroup, LPCTSTR pNewGroup )
{_STTEX();
	HGROUP hGroup = FindGroup( pGroup );
	if ( hGroup == NULL ) return FALSE;

	RemoveGroup( pNewGroup );
	HGROUP hNewGroup = AddGroup( pNewGroup );
	if ( hNewGroup == NULL ) return FALSE;

	// Copy each element
	LPCFGELEMENTINFO pei = NULL;
	while( ( pei = GetNextElement( hGroup, pei ) ) != NULL )
		AddElement( hNewGroup, pei->name, pei->type, pei->size, pei->value );

	return TRUE;
}
void CFeedIcoItemListCtrl::RemoveItemforMap(CRssFeed & feed, int nIndex, bool bUpdate/*=false*/)
{
	if ( m_mapGroups.GetSize() > 0 )
	{
		CString strCatalogName = GetResString( IDS_UNKNOWN );//不是更新的话直接查找IDS_UNKNOWN分组
		if ( !bUpdate && feed.m_uCatalogId != FeedCatalog::INVALID_CATALOG_ID )
		{
			//查找分类名称
			FeedCatalog & catalog = CFeedCatalogs::GetInstance()[feed.m_uCatalogId];
			ASSERT(catalog.m_uId == feed.m_uCatalogId);
			ASSERT(catalog.IsLeaf());

			FeedCatalog * catalogParent;
			if (catalog.m_pParent != NULL)
			{
				catalogParent = catalog.m_pParent;
				strCatalogName = catalogParent->m_strName;
			}
		}


		//查找并删除
		int nGroupId = m_mapGroups.FindKey(strCatalogName);
		if (nGroupId == -1)
			return;

		if (m_mapGroups.GetValueAt(nGroupId).Find(nIndex) != -1)
		{
			m_mapGroups.GetValueAt(nGroupId).Remove(nIndex);

			if ( m_mapGroups.GetValueAt(nGroupId).GetSize() <= 0 && bUpdate )
			{//如果此分组中没有item时应该删除, 因为vista+ 使用系统获取的group进行绘制
				RemoveGroup(nGroupId);//从List中删除此Group
			}
		}
	}
}
Example #16
0
void ExecutiveUser::globalRemoveGroup(const LinqDB& db, const Group& g) {
    std::for_each(db.begin(), db.end(), RemoveGroup(const_cast<Group*> (&g)));
    removeGroup(g);
}
Example #17
0
int32_t ScanGroups(void)
{
    CACHE1D_FIND_REC *srch, *sidx;
    struct grpcache *fg, *fgg;
    struct grpfile *grp;
    char *fn;
    struct Bstat st;
#define BUFFER_SIZE (1024 * 1024 * 8)
    uint8_t *buf = (uint8_t *)Bmalloc(BUFFER_SIZE);

    if (!buf)
    {
        initprintf("Error allocating %d byte buffer to scan GRPs!\n", BUFFER_SIZE);
        return 0;
    }

    initprintf("Searching for game data...\n");

    LoadGameList();
    //LoadGroupsCache(); SB: disabled to match local

    srch = klistpath("/", "*.grp", CACHE1D_FIND_FILE);

    for (sidx = srch; sidx; sidx = sidx->next)
    {
        for (fg = grpcache; fg; fg = fg->next)
        {
            if (!Bstrcmp(fg->name, sidx->name)) break;
        }

        if (fg)
        {
            if (findfrompath(sidx->name, &fn)) continue; // failed to resolve the filename
            if (Bstat(fn, &st))
            {
                Bfree(fn);
                continue;
            } // failed to stat the file
            Bfree(fn);
            if (fg->size == st.st_size && fg->mtime == st.st_mtime)
            {
                grp = (struct grpfile *)Bcalloc(1, sizeof(struct grpfile));
                grp->name = Bstrdup(sidx->name);
                grp->crcval = fg->crcval;
                grp->size = fg->size;
                grp->next = foundgrps;
                foundgrps = grp;

                fgg = (struct grpcache *)Bcalloc(1, sizeof(struct grpcache));
                strcpy(fgg->name, fg->name);
                fgg->size = fg->size;
                fgg->mtime = fg->mtime;
                fgg->crcval = fg->crcval;
                fgg->next = usedgrpcache;
                usedgrpcache = fgg;
                continue;
            }
        }

        {
            int32_t b, fh;
            int32_t crcval;

            fh = openfrompath(sidx->name, BO_RDONLY|BO_BINARY, BS_IREAD);
            if (fh < 0) continue;
            if (Bfstat(fh, &st)) continue;

            initprintf(" Checksumming %s...", sidx->name);
            crc32init((uint32_t *)&crcval);
            do
            {
                b = read(fh, buf, BUFFER_SIZE);
                if (b > 0) crc32block((uint32_t *)&crcval, (uint8_t *)buf, b);
            }
            while (b == BUFFER_SIZE);
            crc32finish((uint32_t *)&crcval);
            close(fh);
            initprintf(" Done\n");

            grp = (struct grpfile *)Bcalloc(1, sizeof(struct grpfile));
            grp->name = Bstrdup(sidx->name);
            grp->crcval = crcval;
            grp->size = st.st_size;
            grp->next = foundgrps;
            foundgrps = grp;

            fgg = (struct grpcache *)Bcalloc(1, sizeof(struct grpcache));
            Bstrncpy(fgg->name, sidx->name, BMAX_PATH);
            fgg->size = st.st_size;
            fgg->mtime = st.st_mtime;
            fgg->crcval = crcval;
            fgg->next = usedgrpcache;
            usedgrpcache = fgg;
        }
    }

    klistfree(srch);
    FreeGroupsCache();

    for (grp = foundgrps; grp; /*grp=grp->next*/)
    {
        struct grpfile *igrp;
        for (igrp = listgrps; igrp; igrp=igrp->next)
            if (grp->crcval == igrp->crcval) break;

        if (igrp == NULL)
        {
            grp = grp->next;
            continue;
        }

        if (igrp->dependency)
        {
            struct grpfile *depgrp;

            //initprintf("found grp with dep\n");
            for (depgrp = foundgrps; depgrp; depgrp=depgrp->next)
                if (depgrp->crcval == igrp->dependency) break;

            if (depgrp == NULL || depgrp->crcval != igrp->dependency) // couldn't find dependency
            {
                //initprintf("removing %s\n", grp->name);
                RemoveGroup(igrp->crcval);
                grp = foundgrps;
                continue;
            }
        }

        if (igrp->game && !grp->game)
            grp->game = igrp->game;

        grp=grp->next;
    }

    if (usedgrpcache)
    {
        int32_t i = 0;
        FILE *fp;
        fp = fopen(GRPCACHEFILE, "wt");
        if (fp)
        {
            for (fg = usedgrpcache; fg; fg=fgg)
            {
                fgg = fg->next;
                fprintf(fp, "\"%s\" %d %d %d\n", fg->name, fg->size, fg->mtime, fg->crcval);
                Bfree(fg);
                i++;
            }
            fclose(fp);
        }
//        initprintf("Found %d recognized GRP %s.\n",i,i>1?"files":"file");

        Bfree(buf);
        return 0;
    }

    initprintf("Found no recognized game data!\n");

    Bfree(buf);
    return 0;
}
 IResourceManager::GroupPtr IResourceManager::RemoveGroup( xst_castring& strName )
 {
     GroupHandle Handle = XSE_HASH( strName );
     return RemoveGroup( Handle );
 }
Example #19
0
void CMyFriend::OnClickedRemove()
{
	// TODO: 在此添加控件通知处理程序代码
	HTREEITEM m_Remove = m_Tree.GetSelectedItem();
	CString TargetRemove = m_Tree.GetItemText(m_Remove);                           //选中的目标项文本
	if (m_Remove == NULL && m_List.GetSelectionMark() == -1)                          //(1).若未选中任何
	{
		MessageBox(_T("尚未选中任何人或组哟~"),_T("删除好友"),MB_OK);
		return;
	}
	if (m_Remove == m_DefalutFocus)                                                       //(2).若选中"我的好友"分组
	{
		MessageBox(_T("这是霸王组,不能删除哟╮(╯▽╰)╭ "),_T("删除好友"),MB_OK);
		return;
	}
	else                                                                                  //选中其他可删除的情况
	{
		if (!m_Tree.GetItemText(m_Tree.GetParentItem(m_Remove)).IsEmpty())               //(3).若选中删除的项不是分组
		{
			RemovePerson_CTreeControl(m_Remove);                                                     //删除选中的好友
			RefreshData();                                                                           //刷新总数据
			return;
		}
		if (!m_Tree.ItemHasChildren(m_Remove) && \
			m_Tree.GetItemText(m_Tree.GetParentItem(m_Remove)).IsEmpty())                //(4).选中没有人的分组时
		{
			RemoveGroup(TargetRemove);                                                                  //删除分组
			RefreshData();                                                                              //刷新总数据
			return;
		}
		if (m_Tree.GetItemText(m_Tree.GetParentItem(m_Remove)).IsEmpty() && \
			m_Tree.ItemHasChildren(m_Remove))                                                  //(5).选中有好友的分组时
		{
			int temp = MessageBox(_T("你选中的一个分组,确定要删除这个分组及里面所有成员吗?"),\
				_T("删除分组及成员"),MB_OKCANCEL);                                  //判断是否选中确定按钮
			if (temp == IDCANCEL)
			{
				return;
			}
			else
			{
				CString Dele_GroupName = m_Tree.GetItemText(m_Remove);                        //获得选中分组的文本
				CString Target_GroupName;                                                            //保存循环所得分组名
				ADO sql;
				sql.OnInitADOConn();                                                                 //初始化数据库连接
				sql.initRecordset();																 //创建记录集实例
				_bstr_t sql_DDL_DELETE_Person = "select * from PersonInfo";							 //sql语句
				sql.m_pReset->Open(sql_DDL_DELETE_Person,sql.m_pConn.GetInterfacePtr(),
					adOpenDynamic,adLockOptimistic,adCmdText);  //打开PersonInfo记录集
				try
				{
					while (!sql.m_pReset->adoEOF)												     //记录集指针不超出末尾记录时执行循环
					{
						Target_GroupName = (char*)(_bstr_t)sql.m_pReset->GetCollect("所在分组");     //保存循环所得分组名
						if (Dele_GroupName == (CString)Target_GroupName)				//判断要删除的人所在分组是否等于选中的分组
						{
							sql.m_pReset->Delete(adAffectCurrent);									//删除该行
						}												    
						sql.m_pReset->MoveNext();													//记录集指针后移一位
					}
					sql.CloseConn();										//断开数据库连接
					RemoveGroup(Dele_GroupName);							//删除所选分组在数据库中的记录
					RefreshData();											//刷新总数据
					return;
				}
				catch(...)
				{
					MessageBox(_T("批量删除好友出错啦(>﹏<)"),_T("批量删除好友"),MB_OK);
					return;
				}
			}
		}
	}
}
Example #20
0
BOOL CCfgFile::RemoveGroup(LPCTSTR pGroup)
{_STTEX();
	return RemoveGroup( FindGroup( pGroup ) );
}
Example #21
0
BOOLEAN StrategicRemoveMerc( SOLDIERTYPE *pSoldier )
{
	UINT8	ubHistoryCode=0;


	if ( gfInContractMenuFromRenewSequence )
	{
		EndCurrentContractRenewal( );
	}

	// ATE: Determine which HISTORY ENTRY to use...
	if ( pSoldier->ubLeaveHistoryCode == 0 )
	{
		// Default use contract expired reason...
		pSoldier->ubLeaveHistoryCode = HISTORY_MERC_CONTRACT_EXPIRED;
	}

	ubHistoryCode = pSoldier->ubLeaveHistoryCode;

	//if the soldier is DEAD
	if( pSoldier->stats.bLife <= 0 )
	{
		AddCharacterToDeadList( pSoldier );
	}

	//else if the merc was fired
	else if( ubHistoryCode == HISTORY_MERC_FIRED || pSoldier->bAssignment == ASSIGNMENT_POW )
	{
		AddCharacterToFiredList( pSoldier );
	}

	//The merc is leaving for some other reason
	else
	{
		AddCharacterToOtherList( pSoldier );
	}


	if( pSoldier->ubWhatKindOfMercAmI == MERC_TYPE__NPC )
	{
		SetupProfileInsertionDataForSoldier( pSoldier );
	}

	if (IsVehicle(pSoldier))
	{
		// for some reason, vehicles have their own idea of handling group ids
		RemovePlayerFromGroup(pVehicleList[ pSoldier->bVehicleID ].ubMovementGroup, pSoldier);
	}
	//remove him from the soldier structure
	if( pSoldier->bAssignment >= ON_DUTY )
	{
		// is he/she in a mvt group, if so, remove and destroy the group
		if( pSoldier->ubGroupID )
		{
			if ( pSoldier->bAssignment != VEHICLE )
			{ //Can only remove groups if they aren't persistant (not in a squad or vehicle)
				RemoveGroup( pSoldier->ubGroupID );
			}
			else
			{
				// remove him from any existing merc slot he could be in
				RemoveMercSlot( pSoldier );
		TakeSoldierOutOfVehicle( pSoldier );
			}
		}

	}
	else
	{
		RemoveCharacterFromSquads( pSoldier );
	}

	// if the merc is not dead
	if( gMercProfiles[ pSoldier->ubProfile ].bMercStatus != MERC_IS_DEAD )
	{
		//Set the status to returning home ( delay the merc for rehire )
		gMercProfiles[ pSoldier->ubProfile ].bMercStatus = MERC_RETURNING_HOME;

		// specify how long the merc will continue to be unavailable
		gMercProfiles[ pSoldier->ubProfile ].uiDayBecomesAvailable = 1 + Random(2);		// 1-2 days

		HandleSoldierLeavingWithLowMorale( pSoldier );
		HandleSoldierLeavingForAnotherContract( pSoldier );
	}


	//add an entry in the history page for the firing/quiting of the merc
	// ATE: Don't do this if they are already dead!
	if ( !( pSoldier->flags.uiStatusFlags & SOLDIER_DEAD ) )
	{
		AddHistoryToPlayersLog( ubHistoryCode, pSoldier->ubProfile, GetWorldTotalMin(), pSoldier->sSectorX, pSoldier->sSectorY );
	}

	//if the merc was a POW, remember it becuase the merc cant show up in AIM or MERC anymore
	if( pSoldier->bAssignment	== ASSIGNMENT_POW )
	{
		gMercProfiles[ pSoldier->ubProfile ].bMercStatus = MERC_FIRED_AS_A_POW;
	}

	//else the merc CAN get his medical deposit back
	else
	{
		//Determine how much of a Medical deposit is going to be refunded to the player
		CalculateMedicalDepositRefund( pSoldier );
	}

	//remove the merc from the tactical
	TacticalRemoveSoldier( pSoldier->ubID );

	// Check if we should remove loaded world...
	CheckAndHandleUnloadingOfCurrentWorld();

	if ( guiTacticalInterfaceFlags & INTERFACE_MAPSCREEN )
	{
		ReBuildCharactersList( );
	}

	fMapPanelDirty = TRUE;
	fTeamPanelDirty = TRUE;
	fCharacterInfoPanelDirty = TRUE;

	// stop time compression so player can react to the departure
	StopTimeCompression();

	// WDS: This allows for replacing dead IMP mercs.	See "BtnIMPBeginScreenDoneCallback" in "IMP Begin Screen.cpp"
	if( ( pSoldier->ubWhatKindOfMercAmI == MERC_TYPE__PLAYER_CHARACTER ) &&
		( gMercProfiles[ pSoldier->ubProfile ].bMercStatus == MERC_IS_DEAD ) ) {
		// Replace the name with an empty string
		wcsncpy( gMercProfiles[ pSoldier->ubProfile ].zName, L"", 1 );
	}

	// ATE: update team panels....
	UpdateTeamPanelAssignments( );
 
	// And unpause the @#$@#$ interface
	UnLockPauseState();
	UnPauseGame();


	if (is_client)
		send_dismiss(pSoldier->ubID);

	return( TRUE );
}
 IResourceManager::GroupPtr IResourceManager::RemoveGroup( const GroupWeakPtr pGroup )
 {
     return RemoveGroup( pGroup->GetHandle() );
 }