Exemple #1
0
static boolean SetupList(searchlist_t *list, searchlist_t *src_list,
                         char *startname, char *endname, char *startname2, char *endname2)
{
    int startlump, endlump;

    list->numlumps = 0;
    startlump = FindInList(src_list, startname);

    if (startname2 != NULL && startlump < 0)
        startlump = FindInList(src_list, startname2);

    if (startlump >= 0)
    {
        endlump = FindInList(src_list, endname);

        if (endname2 != NULL && endlump < 0)
            endlump = FindInList(src_list, endname2);

        if (endlump > startlump)
        {
            list->lumps = src_list->lumps + startlump + 1;
            list->numlumps = endlump - startlump - 1;
            return true;
        }
    }

    return false;
}
void CUserListCtrl::OnUserCreatenewuser() 
{
	if (m_EditInProgress)
	{
		CantEditRightNow(IDS_USER);
		return;
	}

	MainFrame()->ViewUsers();
	m_olduser = GET_P4REGPTR()->GetP4User( );

	//		let user type in the new name. if it's blank the user bailed.
	//

	CNewClientDlg newdlg;
	newdlg.SetNew( NEWUSER );
	if (FindInList(m_Active) != -1)
		newdlg.m_Active = m_Active;
	if( newdlg.DoModal( ) == IDCANCEL )
		return;

	CString saveActive = m_Active;
	m_Active = newdlg.GetName( ) ;
	if ( m_Active.IsEmpty( ) )
	{
		m_Active = saveActive;
		return;
	}
	if (FindInListNoCase(m_Active) != -1)
	{
		CString msg;
		UINT nType;
		if (FindInList(m_Active) != -1)
		{
			msg.FormatMessage ( IDS_USER_s_ALREADY_EXIST, m_Active );
			nType = MB_OK;
		}
		else
		{
			msg.FormatMessage ( IDS_USER_s_DIFFCASE_EXIST, m_Active );
			nType = MB_YESNO;
		}
		if (IDYES != AfxMessageBox( msg, nType ))
		{
			m_Active = saveActive;
			return;
		}
	}

    if ( SetP4User( ) ) 
		OnEditSpec( m_Active, TRUE );
}
void CClientListCtrl::OnNewClient(WPARAM wParam, LPARAM lParam)
{
	if (!IsClear())
	{
		CString oldclient = wParam ? m_OldDefClient : m_OldCurClient;
		CString newclient = GET_P4REGPTR()->GetP4Client((BOOL)wParam);
		CString curclient = GET_P4REGPTR()->GetP4Client();
		CString defclient = GET_P4REGPTR()->GetP4Client(TRUE);
		LV_ITEM lvItem;
		lvItem.mask = LVIF_IMAGE;
		lvItem.iSubItem = 0;
		lvItem.state = lvItem.stateMask = 0;

		lvItem.iItem = FindInList(oldclient);
		if(lvItem.iItem > -1)
		{
			lvItem.iImage = CP4ViewImageList::GetClientIndex(false,
				oldclient == defclient);
			SetItem(&lvItem );
		}

		lvItem.iItem = FindInList(newclient);
		if(lvItem.iItem > -1)
		{
	        lvItem.iImage = CP4ViewImageList::GetClientIndex(true,
				newclient == defclient);
			SetItem(&lvItem );
		}
		else if (GET_P4REGPTR()->GetClientFilteredFlags())
		{
			int index = FindInListAll(newclient);
			if (index > -1)
			{
				CP4Client * client = new CP4Client;
				client->Create(m_ListAll.column[CLIENT_NAME].GetAt(index),
							  m_ListAll.column[CLIENT_OWNER].GetAt(index),
							  m_ListAll.column[CLIENT_HOST].GetAt(index),
							  m_ListAll.column[CLIENT_ACCESSDATE].GetAt(index),
							  m_ListAll.column[CLIENT_ROOT].GetAt(index),
							  m_ListAll.column[CLIENT_DESC].GetAt(index));
				m_ListAll.column[0].SetAt(index, _T("@@"));	// Removes from list of all clients
				InsertClient(client, GetItemCount(), &curclient, &defclient);
				ReSort();
			}
		}
		if (wParam)
			m_OldDefClient = newclient;
		else
			m_OldCurClient = newclient;
	}
}
/* ------------------------------------------------------------------------------------ */
int CAudioStream::Stop(const char *szFilename)
{
	if((szFilename == NULL) || (strlen(szFilename) <= 0))
		return false;							// You're kidding, right?

// FIX #1
	char szTemp[256];
	strcpy(szTemp, CCD->GetDirectory(kAudioStreamFile));
	strcat(szTemp, "\\");
	strcat(szTemp, szFilename);
// FIX #1

	int nSlot = FindInList(szTemp);

	if(nSlot < 0)
	  return false;							// No such, not playing

	// Ok, stop playback, kill the stream, and clean up the table
	int nError = m_Streams[nSlot]->Stop();

	delete m_Streams[nSlot];
	m_Streams[nSlot] = NULL;
	delete m_FileList[nSlot];
	m_FileList[nSlot] = NULL;

	return nError;
}
Exemple #5
0
bool CRusFormatCaller::format_for_modif_adj_groups (CGroup& G)
{
    if (get_maximal_group_no(G.m_iFirstWord) != -1) return  false;    
    int j =  G.m_iFirstWord;

    if( FindInList((const char*)g_strAdjModif, g_AdjModifCount, Wj.get_lemma()) == -1)
        return false;


    if( j+1 >= sent.size() )
        return false;
    const CGroup& H = get_maximal_group(j+1);
    if( !is_morph_adj(sent[H.m_MainWordNo]) )
            return false;

    if( !GetGramTab()->GleicheGenderNumberCase(sent[H.m_MainWordNo].m_type_gram_code, sent[H.m_MainWordNo].m_gramcodes, Wj.m_gramcodes ) )
        return false;

    G.m_iLastWord = H.m_iLastWord;
    G.m_GroupType = MODIF_ADJ;
    G.SetGrammems (H.GetGrammems() & sent[j].GetGrammems());
    G.m_MainGroup =  H;
    change_words_in_group_grammems(G, G.GetGrammems(), (rAllNumbers | rAllCases));  
    create_syn_rel(G, H.m_MainWordNo, j , MODIF_ADJ);
    return true;
}
Exemple #6
0
char *BreakWord(register char *iptr, register char *fbuf, 
	WLIST *skiplist, short skiptype)	
/* returns next iptr  wbuf should be 128 bytes */
{
	if((*iptr=='.')||(*iptr==';')||(*iptr==','))
		return(NULL);		/* Phrase end */
	if((*iptr==':')||(*iptr=='"')||(*iptr=='/')||(*iptr=='\''))
	{
		*fbuf++=*iptr++;
		*fbuf=0;
		return(iptr);
	}
l1:	while(*iptr)
		if(isspace(*iptr))
			iptr++;
		else
			break;
	if(!*iptr)
		return(NULL);		/* List expired */
	if((*iptr=='.')||(*iptr==';')||(*iptr==','))
		return(NULL);		/* Phrase end */
	while(*iptr)
		if((!isspace(*iptr))&&(*iptr!=',')&&(*iptr!=';')&&(*iptr!='.'))
			*fbuf++=*iptr++;
		else
			break;
	*fbuf=0;
	if(stricmp(fbuf,"AND")==0)
		return(NULL);
	if(stricmp(fbuf,"THEN")==0)
		return(NULL);
	if(FindInList(skiplist,fbuf,skiptype))
		goto l1;
	return(iptr);
}
Exemple #7
0
int GetVerb(void)
{
	char *a=WordPtr;
	register WLIST *b;
	b=GetWord();
	if(b==(WLIST *)-1)
	{
		WordPtr=a;
		return(-1);
	}
	if(b==NULL)
	{
		WordPtr=a;
		return(-1);
	}
	if(b->wd_Type!=WD_VERB)
	{
		b=FindInList(WordList,WordBuffer,WD_VERB);
		if(!b)
		{
			WordPtr=a;
			return(-1);
		}
	}
	return(b->wd_Code);
}
LRESULT CClientListCtrl::OnP4ClientList(WPARAM wParam, LPARAM lParam)
{
	CCmd_Clients *pCmd= (CCmd_Clients *) wParam;

	if(!pCmd->GetError())
	{
		CString msg;
		CObList const *clients= pCmd->GetList();
		int count = clients->GetCount();

		SetRedraw(FALSE);
    	int index = 0;
		CString curclient = GET_P4REGPTR()->GetP4Client();
		CString defclient = GET_P4REGPTR()->GetP4Client(TRUE);
		CString user      = GET_P4REGPTR()->GetP4User();
		for(int subItem=0; subItem < CLIENT_MAXCOL; subItem++)
			m_ListAll.column[subItem].SetSize(clients->GetCount(), 100);
		for(POSITION pos= clients->GetHeadPosition(); pos != NULL; index++)
		{
			CP4Client *client=(CP4Client *) clients->GetNext(pos);
			InsertClient(client, index, &curclient, &defclient, &user);
			if ((index & 0x1FFF) == 0)
			{
				msg.FormatMessage(IDS_INSERTING_CLIENTS, count - index);
				MainFrame()->UpdateStatus(msg);
			}
		}
        SetRedraw(TRUE);

		msg.FormatMessage( IDS_NUMBER_OF_CLIENTS_n, index );
		AddToStatus( msg, SV_COMPLETION );

		ReSort();

		// Make sure previous item is re-selected
		if(clients->GetCount() > 0)
		{
			int i = FindInList(m_Active.IsEmpty() ? GET_P4REGPTR()->GetP4Client() : m_Active);
			if (i < 0)	i=0;
			SetItemState(i, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);
			EnsureVisible(i, FALSE);
		}

		CP4ListCtrl::SetUpdateDone();
		// Notify the mainframe that we have finished getting the clients,
		// hence the entire set of async command have finished.
		MainFrame()->ExpandDepotIfNeedBe();
		if (m_PostViewUpdateMsg)
			PostMessage(m_PostViewUpdateMsg, m_PostViewUpdateWParam, m_PostViewUpdateLParam);
	}
	else
		CP4ListCtrl::SetUpdateFailed();
	
	delete pCmd;
	m_PostViewUpdateMsg = 0;
	MainFrame()->ClearStatus();
	return 0;
}
Exemple #9
0
WLIST *GetWord(void)
{
	WLIST *a;
	WordPtr=BreakWord(WordPtr,WordBuffer,WordList,WD_NOISE);
	if(!WordPtr)
		return((WLIST *)-1);
	a=FindInList(WordList,WordBuffer,0);
	return(a);
}
Exemple #10
0
int main(int argc, const char *argv[])
{
  Node* head = CreateList();
  int v = 5;
  InsertList(head, v);
  InsertList(head, v);
  InsertList(head, v);
  v = 10;
  int i = InsertList(head, v, 4);
  v = 20;
  i = InsertList(head, v, 4);
  v = 1;
  i = InsertList(head, v);
  printf("i:%d\n", i);
  PList(head);
  printf("\n\n");
  PListRecurse(head->next);

  printf("\nreserve list:\n");
  ReserveList(head);
  PList(head);
  printf("\n---- reserve list\n");

  Node* p = GetNode(head, 1);
  if( NULL != p )
  {
    printf("\n0 node d:%d p:%016lX\n", p->d, reinterpret_cast<uint64_t>(p));
  }

  Node* head2 = CreateList();
  head2->next = p;
  printf("\nlist2\n");
  PList(head2);
  printf("\n");

  int retInterSection = CheckUnion(head, head2);
  printf("checkunion ret:%d\n", retInterSection);

  int ret = CheckCircle(head);
  printf("check circle:%d\n", ret);

  printf("makecircle \n");
  MakeCircle(head);
  //PList(head);

  retInterSection = CheckUnion(head, head2);
  printf("checkunion2 ret:%d\n", retInterSection);

  ret = CheckCircle(head);
  printf("check circle:%d\n", ret);

  i = FindInList(head, 20);
  printf("\nfind i:%d\n", i);
  
  return 0;
}
Exemple #11
0
LRESULT CUserListCtrl::OnP4UserList(WPARAM wParam, LPARAM lParam)
{
	CCmd_Users *pCmd= (CCmd_Users *) wParam;

	if(!pCmd->GetError())
	{
	    CObList const *users = pCmd->GetList();

        SetRedraw(FALSE);
    	int index = 0;
		for(POSITION pos= users->GetHeadPosition(); pos != NULL; index++)
		{
        	CP4User *user = (CP4User *) users->GetNext(pos);
			InsertUser(user, index);
		}
        SetRedraw(TRUE);
		
		CString msg;
		msg.FormatMessage( IDS_NUMBER_OF_USERS_n, index );
		AddToStatus( msg, SV_COMPLETION );

		ReSort();

		// Make sure previous item is re-selected
		if(users->GetCount() > 0)
		{
			int i = FindInList(m_Active.IsEmpty() 
				? GET_P4REGPTR()->GetP4User() : m_Active);
			if (i < 0)	
				i=0;
			SetItemState(i, LVIS_SELECTED|LVIS_FOCUSED, 
				LVIS_SELECTED|LVIS_FOCUSED);
			EnsureVisible(i, FALSE);
			// If m_Active is empty but we found the current user in the list,
			// then set m_Active to the correct value
			if (m_Active.IsEmpty() && i >= 0)
				m_Active = GET_P4REGPTR()->GetP4User();
		}

		CP4ListCtrl::SetUpdateDone();
		// Notify the mainframe that we have finished getting the users,
		// hence the entire set of async command have finished.
		MainFrame()->ExpandDepotIfNeedBe();
		if (m_PostViewUpdateMsg)
			PostMessage(m_PostViewUpdateMsg, m_PostViewUpdateWParam, m_PostViewUpdateLParam);
	}
	else
		CP4ListCtrl::SetUpdateFailed();
	
		
	delete pCmd;
	m_PostViewUpdateMsg = 0;
	MainFrame()->ClearStatus();
	return 0;
}
Exemple #12
0
/*
**  Purpose:	Capture all requests to free information and also
**		remove items from the allocation list.
**  Arguments:	vp_Alloced	The memory to free.
**		cp_File		The file calling free.
**		ssi_Line	The line of cp_File calling free.
**  Return Value:	void
**  Remarks/Portability/Dependencies/Restrictions:
**		If the pointer value is invalid, then an item will be added
**		to the list and nothing else is done.
**		I really like the name of this function and one day hope
**		that Lynx is Leak Free.
**  Revision History:
**	05-26-94	created Lynx 2-3-1 Garrett Arch Blythe
*/
PUBLIC void LYLeakFree ARGS3(
	void *,		vp_Alloced,
	CONST char *,	cp_File,
	CONST short,	ssi_Line)
{
    AllocationList *ALp_free;

    if (LYfind_leaks == FALSE) {
	free(vp_Alloced);
	return;
    }

    /*
     *	Find the pointer in the allocated list.
     *	If not found, bad pointer.
     *	If found, free list item and vp_Allloced.
     */
    ALp_free = FindInList(vp_Alloced);
    if (ALp_free == NULL) {
	/*
	 *  Create the final entry before exiting marking this error.
	 *  If unable to allocate more memory just exit.
	 */
	AllocationList *ALp_new = typecalloc(AllocationList);

	if (ALp_new == NULL) {
	    exit(EXIT_FAILURE);
	}

	/*
	 *  Set up the information, no memory need be allocated
	 *  for the file name since it is a static string.
	 */
	ALp_new->vp_Alloced = NULL;
	ALp_new->vp_BadRequest = vp_Alloced;
	ALp_new->SL_memory.cp_FileName = cp_File;
	ALp_new->SL_memory.ssi_LineNumber = ssi_Line;

	/*
	 *  Add the entry to the list and then return.
	 */
	AddToList(ALp_new);
	return;
    } else {
	/*
	 *  Free off the memory.
	 *  Take entry out of allocation list.
	 */
	CountFrees(ALp_free->st_Bytes);
	RemoveFromList(ALp_free);
	FREE(ALp_free);
	FREE(vp_Alloced);
    }
}
LRESULT CLabelListCtrl::OnP4EndSpecEdit( WPARAM wParam, LPARAM lParam )
{
	CCmd_EditSpec *pCmd= (CCmd_EditSpec *) wParam;
	int index;

	if (lParam != IDCANCEL && lParam != IDABORT)
	{
		if (m_UpdateState == LIST_UPDATED)
		{
			if(m_NewLabel && FindInList(m_pNewSpec->GetLabelName()) == -1)
			{
				InsertLabel(m_pNewSpec, GetItemCount());
				ReSort();
				index= FindInList(m_pNewSpec->GetLabelName());
			}
			else
			{
				index= FindInList(m_pNewSpec->GetLabelName());
				UpdateLabel(m_pNewSpec, index);
			}
			EnsureVisible(index, TRUE );
			SetItemState(index, LVIS_SELECTED|LVIS_FOCUSED, LVIS_DROPHILITED|LVIS_SELECTED|LVIS_FOCUSED );
		}
		else
			if ( m_pNewSpec ) delete m_pNewSpec;
	}
	else
		if ( m_pNewSpec ) delete m_pNewSpec;

	if (lParam != IDABORT)
	{
		MainFrame()->ClearStatus();
		if (pCmd->HaveServerLock())
			pCmd->ReleaseServerLock();
		CDialog *dlg = (CDialog *)pCmd->GetSpecSheet();
		dlg->DestroyWindow();
	}
	delete pCmd;
	m_EditInProgress = FALSE;
	return 0;
}
Exemple #14
0
/*
**  Purpose:	Add information about new allocation to the list,
**		after a call to malloc or calloc or an equivalent
**		function which may or may not have already created
**		a list entry.
**  Arguments:	vp_malloc	The pointer to newly allocated memory.
**  Arguments:	st_bytes	The size of the allocation requested
**				in bytes.
**		cp_File		The file from which the request for
**				allocation came from.
**		ssi_Line	The line number in cp_File where the
**				allocation request came from.
**  Return Value:	void *	A pointer to the allocated memory or NULL on
**				failure.
**  Remarks/Portability/Dependencies/Restrictions:
**		If no memory is allocated, then no entry is added to the
**		allocation list.
**  Revision History:
**	1999-02-08	created, modelled after LYLeakMalloc - kw
*/
PUBLIC AllocationList *LYLeak_mark_malloced ARGS4(
	void *,		vp_malloced,
	size_t,		st_bytes,
	CONST char *,	cp_File,
	CONST short,	ssi_Line)
{
    AllocationList *ALp_new = NULL;

    if (LYfind_leaks == FALSE)
	return NULL;

    /*
     *	The actual allocation has already been done!
     *
     *	Only on successful allocation do we track any information.
     */
    if (vp_malloced != NULL) {
	/*
	 *  See if there is already an entry.  If so, just
	 *  update the source location info.
	 */
	ALp_new = FindInList(vp_malloced);
	if (ALp_new) {
	    ALp_new->SL_memory.cp_FileName = cp_File;
	    ALp_new->SL_memory.ssi_LineNumber = ssi_Line;
	    return(ALp_new);
	}
	/*
	 *  Further allocate memory to store the information.
	 *  Just return on failure to allocate more.
	 */
	ALp_new = typecalloc(AllocationList);

	if (ALp_new == NULL) {
	    return(NULL);
	}
	/*
	 *  Copy over the relevant information.
	 */
	ALp_new->vp_Alloced = vp_malloced;
	ALp_new->st_Bytes = st_bytes;
	ALp_new->SL_memory.cp_FileName = cp_File;
	ALp_new->SL_memory.ssi_LineNumber = ssi_Line;

	/*
	 *  Add the new item to the allocation list.
	 */
	AddToList(ALp_new);
    }

    return(ALp_new);
}
Exemple #15
0
void CUserListCtrl::OnUserEditmy() 
{
	m_Active = GET_P4REGPTR()->GetP4User();
	
	int index = FindInList(GET_P4REGPTR()->GetP4User());
	if(index > -1)
	{
		SetItemState(index, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);
		EnsureVisible(index, FALSE);
	}

    m_olduser= m_Active;
	OnEditSpec( m_Active );
}
void Menu::Update(void)
{
	if (!IsOnScreen(m_focus))
	{
		int dir = FindInList(m_topView, m_focus);
		if (dir == 0)
		{
			// Item not in list? Suspicious
			return;
		}
		if (dir < 0)
		{
			// First, move up until view is visible
			do
			{
				do
				{
					m_topView = m_topView->m_last;
				}
				while ((m_topView != NULL) && (!m_topView->Visible()));
			}
			while (!IsOnScreen(m_focus));
			// Second, optionally find top label
			Control *label = m_topView->m_last;
			while ((label != NULL) && ((!label->Visible()) || label->CanFocus()))
				label = label->m_last;
			if (label != NULL)
			{
				Control *minTop = m_topView;
				m_topView = label;
				if (!IsOnScreen(m_focus))
					m_topView = minTop;
			}
		}
		else
		{
			// Simply move down until item visible
			do
			{
				do
				{
					m_topView = m_topView->m_next;
				}
				while (!m_topView->Visible());
			}
			while (!IsOnScreen(m_focus));
		}
	}
	OnPaint(m_destination);
}
Exemple #17
0
void W_NWTDashMerge(char *filename)
{
    wad_file_t *wad_file;
    int old_numlumps;
    int i;

    old_numlumps = numlumps;

    // Load PWAD

    wad_file = W_AddFile(filename);

    if (wad_file == NULL)
    {
        return;
    }

    // IWAD is at the start, PWAD was appended to the end

    iwad.lumps = lumpinfo;
    iwad.numlumps = old_numlumps;

    pwad.lumps = lumpinfo + old_numlumps;
    pwad.numlumps = numlumps - old_numlumps;

    // Setup sprite/flat lists

    SetupLists();

    // Search through the IWAD sprites list.

    for (i=0; i<iwad_sprites.numlumps; ++i)
    {
        if (FindInList(&pwad, iwad_sprites.lumps[i]->name) >= 0)
        {
            // Replace this entry with an empty string.  This is what
            // nwt -merge does.

            M_StringCopy(iwad_sprites.lumps[i]->name, "", 8);
        }
    }

    // Discard PWAD
    // The PWAD must now be added in again with -file.

    numlumps = old_numlumps;

    W_CloseFile(wad_file);
}
void CToolCervicales::AddNeighbors(CDib * m_Dib, CList<CPoint, CPoint&>& i_List, CPoint& i_Point, int i_Direction){
	i_List.AddTail(i_Point);
	CPoint n_Point;
	for (int i=0;i<8;i+=2){
		if ((i + 4 == i_Direction)||(i - 4 == i_Direction)) continue;
		n_Point = GetNPoint(i_Point, i);
		if ((n_Point.x >= 0)&&(n_Point.x < m_Dib->GetWidth())) {
			if ((n_Point.y >= 0)&&(n_Point.y < m_Dib->GetHeight())) {
				if ((m_Dib->GetPixel(n_Point.x, n_Point.y) == 0)&&(FindInList(i_List, n_Point) == -1)) {
					AddNeighbors(m_Dib, i_List, n_Point, i);
				}
			}
		}
	}
}
void CClientListCtrl::OnClientEditmy() 
{
	m_Active = GET_P4REGPTR()->GetP4Client();
	m_OldClient= m_Active;
	m_NewClicked = m_NewClient = FALSE;

	int index = FindInList( m_Active ) ;
	if ( index  > -1 )
	{
		SetItemState(index, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);
		EnsureVisible(index, FALSE);
	}

	OnEditSpec( m_Active );
}
Exemple #20
0
void CUserListCtrl::OnNewUser(WPARAM wParam, LPARAM lParam)
{
	if (!IsClear())
	{
		CString olduser = wParam ? m_OldDefUser : m_OldCurUser;
		CString newuser = GET_P4REGPTR()->GetP4User((BOOL)wParam);
		CString defuser = GET_P4REGPTR()->GetP4User(TRUE);
		LV_ITEM lvItem;
		lvItem.mask = LVIF_IMAGE;
		lvItem.iSubItem = 0;
		lvItem.state = lvItem.stateMask = 0;

		lvItem.iItem = FindInList(olduser);
		if(lvItem.iItem > -1)
		{
			lvItem.iImage = CP4ViewImageList::GetUserIndex(false,
				olduser == defuser);
			SetItem(&lvItem);
		}

		lvItem.iItem = FindInList(newuser);
		if(lvItem.iItem > -1)
		{
			lvItem.iImage = CP4ViewImageList::GetUserIndex(true,
				newuser == defuser);
			SetItem(&lvItem);
		}
		if (wParam)
			m_OldDefUser = newuser;
		else
			m_OldCurUser = newuser;
	}
	::PostMessage(m_clientWnd, WM_NEWUSER, 0, 0);
	::PostMessage(m_branchWnd, WM_NEWUSER, 0, 0);
	::PostMessage(m_labelWnd,  WM_NEWUSER, 0, 0);
}
        virtual bool ShouldCreateEntity( const char *pClassname )
        {
            // Don't recreate the preserved entities.
            if ( !FindInList( s_PreserveEnts, pClassname ) )
            {
                return true;
            }
            else
            {
                // Increment our iterator since it's not going to call CreateNextEntity for this ent.
                if ( m_iIterator != g_MapEntityRefs.InvalidIndex() )
                    m_iIterator = g_MapEntityRefs.Next( m_iIterator );

                return false;
            }
        }
Exemple #22
0
static void
UpdateListener( ARRAY8Ptr addr, void **closure )
{
	struct socklist *s;

	*closure = NULL;

	if (addr == NULL) {
		ARRAY8 tmpaddr;
		struct in_addr in;
#if defined(IPv6) && defined(AF_INET6)
		struct in6_addr in6 = in6addr_any;
		tmpaddr.length = sizeof(in6);
		tmpaddr.data = (CARD8Ptr) &in6;
		UpdateListener( &tmpaddr, closure );
		if (*closure)
			return;
#endif
		in.s_addr = htonl( INADDR_ANY );
		tmpaddr.length = sizeof(in);
		tmpaddr.data = (CARD8Ptr) &in;
		UpdateListener( &tmpaddr, closure );
		return;
	}

	if (c_request_port == request_port &&
	    (s = FindInList( listensocks, addr )))
	{
		*closure = (void *)s;
		s->ref = 1;
		return;
	}

	if (!(s = CreateSocklistEntry( addr )))
		return;

	if ((s->fd = CreateListeningSocket( s->addr, s->salen )) < 0) {
		free( s->addr );
		free( s );
		return;
	}
	s->ref = 1;
	s->next = listensocks;
	listensocks = s;
	*closure = (void *)s;
}
Exemple #23
0
static void W_NWTAddLumps(searchlist_t *list)
{
    int i;

    // Go through the IWAD list given, replacing lumps with lumps of
    // the same name from the PWAD
    for (i=0; i<list->numlumps; ++i)
    {
        int index;

        index = FindInList(&pwad, list->lumps[i]->name);

        if (index > 0)
        {
            memcpy(list->lumps[i], pwad.lumps[index],
                   sizeof(lumpinfo_t));
        }
    }
}
/* ------------------------------------------------------------------------------------ */
int CAudioStream::Pause(const char *szFilename)
{
	if((szFilename == NULL) || (strlen(szFilename) <= 0))
		return false;							// You're kidding, right?

// FIX #1
	char szTemp[256];
	strcpy(szTemp, CCD->GetDirectory(kAudioStreamFile));
	strcat(szTemp, "\\");
	strcat(szTemp, szFilename);
// FIX #1

	int nSlot = FindInList(szTemp);

	if(nSlot < 0)
		return false;							// No such, not playing

	return m_Streams[nSlot]->Pause();
}
void CLabelListCtrl::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
{
	CP4ListCtrl::OnActivate(nState, pWndOther, bMinimized);

	if(nState != WA_INACTIVE && m_Active.IsEmpty() && GetItemCount() > 1)
	{
		int i = FindInList(GET_P4REGPTR()->GetLastLabel());
		if (i < 0)	
			i=0;
		SetItemState(i, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);
		EnsureVisible(i, FALSE);
		m_Active=GetSelectedItemText();
	}
	else
	{
		m_Active=GetSelectedItemText();
		if (!m_Active.IsEmpty())
			GET_P4REGPTR()->SetLastLabel(m_Active);
	}
}
Exemple #26
0
static void
UpdateMcastGroup( ARRAY8Ptr addr, void **closure )
{
	struct socklist *s = (struct socklist *)*closure;
	struct socklist *g;

	if (!s)
		return;

	/* Already in the group, mark & continue */
	if ((g = FindInList( s->mcastgroups, addr ))) {
		g->ref = 1;
		return;
	}

	/* Need to join the group */
	if (!(g = CreateSocklistEntry( addr )))
		return;

	ChangeMcastMembership( s, g, JOIN_MCAST_GROUP );
	free( g );
}
Exemple #27
0
int GetPrep(void)
{
	char *a=WordPtr;
	register WLIST *b;
l1:	b=GetWord();
	if(b==(WLIST *)-1)
	{
		WordPtr=a;
		return(-1);
	}
	if(b==NULL)
		goto l1;	/* Dud word */
	if(b->wd_Type!=WD_PREP)
	{
		b=FindInList(WordList,WordBuffer,WD_PREP);
		if(!b)
		{
			WordPtr=a;
			return(-1);
		}
	}
	return(b->wd_Code);
}
Exemple #28
0
// Perform the merge.
//
// The merge code creates a new lumpinfo list, adding entries from the
// IWAD first followed by the PWAD.
//
// For the IWAD:
//  * Flats are added.  If a flat with the same name is in the PWAD,
//    it is ignored(deleted).  At the end of the section, all flats in the
//    PWAD are inserted.  This is consistent with the behavior of
//    deutex/deusf.
//  * Sprites are added.  The "replace list" is generated before the merge
//    from the list of sprites in the PWAD.  Any sprites in the IWAD found
//    to match the replace list are removed.  At the end of the section,
//    the sprites from the PWAD are inserted.
//
// For the PWAD:
//  * All Sprites and Flats are ignored, with the assumption they have
//    already been merged into the IWAD's sections.
static void DoMerge(void)
{
    section_t           current_section;
    lumpinfo_t          *newlumps;
    int                 num_newlumps;
    int                 lumpindex;
    int                 i, n;

    // Can't ever have more lumps than we already have
    newlumps = (lumpinfo_t *)malloc(sizeof(lumpinfo_t) * numlumps);
    num_newlumps = 0;

    // Add IWAD lumps
    current_section = SECTION_NORMAL;

    for (i = 0; i < iwad.numlumps; ++i)
    {
        lumpinfo_t      *lump = &iwad.lumps[i];

        switch (current_section)
        {
            case SECTION_NORMAL:
                if (!strncasecmp(lump->name, "F_START", 8))
                    current_section = SECTION_FLATS;
                else if (!strncasecmp(lump->name, "S_START", 8))
                    current_section = SECTION_SPRITES;

                newlumps[num_newlumps++] = *lump;

                break;

            case SECTION_FLATS:

                // Have we reached the end of the section?
                if (!strncasecmp(lump->name, "F_END", 8))
                {
                    // Add all new flats from the PWAD to the end
                    // of the section
                    for (n = 0; n < pwad_flats.numlumps; ++n)
                        newlumps[num_newlumps++] = pwad_flats.lumps[n];

                    newlumps[num_newlumps++] = *lump;

                    // back to normal reading
                    current_section = SECTION_NORMAL;
                }
                else
                {
                    // If there is a flat in the PWAD with the same name,
                    // do not add it now.  All PWAD flats are added to the
                    // end of the section. Otherwise, if it is only in the
                    // IWAD, add it now
                    lumpindex = FindInList(&pwad_flats, lump->name);

                    if (lumpindex < 0)
                        newlumps[num_newlumps++] = *lump;
                }

                break;

            case SECTION_SPRITES:

                // Have we reached the end of the section?
                if (!strncasecmp(lump->name, "S_END", 8))
                {
                    // add all the pwad sprites
                    for (n = 0; n < pwad_sprites.numlumps; ++n)
                    {
                        if (SpriteLumpNeeded(&pwad_sprites.lumps[n]))
                            newlumps[num_newlumps++] = pwad_sprites.lumps[n];
                    }

                    // copy the ending
                    newlumps[num_newlumps++] = *lump;

                    // back to normal reading
                    current_section = SECTION_NORMAL;
                }
                else
                {
                    // Is this lump holding a sprite to be replaced in the
                    // PWAD? If so, wait until the end to add it.
                    if (SpriteLumpNeeded(lump))
                        newlumps[num_newlumps++] = *lump;
                }

                break;
        }
    }

    // Add PWAD lumps
    current_section = SECTION_NORMAL;

    for (i = 0; i < pwad.numlumps; ++i)
    {
        lumpinfo_t *lump = &pwad.lumps[i];

        switch (current_section)
        {
            case SECTION_NORMAL:
                if (!strncasecmp(lump->name, "F_START", 8) ||
                    !strncasecmp(lump->name, "FF_START", 8))
                    current_section = SECTION_FLATS;
                else if (!strncasecmp(lump->name, "S_START", 8) ||
                         !strncasecmp(lump->name, "SS_START", 8))
                    current_section = SECTION_SPRITES;
                else
                {
                    // Don't include the headers of sections
                    newlumps[num_newlumps++] = *lump;
                }
                break;

            case SECTION_FLATS:

                // PWAD flats are ignored (already merged)
                if (!strncasecmp(lump->name, "FF_END", 8) ||
                    !strncasecmp(lump->name, "F_END", 8))
                {
                    // end of section
                    current_section = SECTION_NORMAL;
                }
                break;

            case SECTION_SPRITES:

                // PWAD sprites are ignored (already merged)
                if (!strncasecmp(lump->name, "SS_END", 8) ||
                    !strncasecmp(lump->name, "S_END", 8))
                {
                    // end of section
                    current_section = SECTION_NORMAL;
                }
                break;
        }
    }

    // Switch to the new lumpinfo, and free the old one
    free(lumpinfo);
    lumpinfo = newlumps;
    numlumps = num_newlumps;

}
void CHL2MPRules::CleanUpMap()
{
    // Recreate all the map entities from the map data (preserving their indices),
    // then remove everything else except the players.

    // Get rid of all entities except players.
    CBaseEntity *pCur = gEntList.FirstEnt();
    while ( pCur )
    {
        CBaseHL2MPCombatWeapon *pWeapon = dynamic_cast< CBaseHL2MPCombatWeapon* >( pCur );
        // Weapons with owners don't want to be removed..
        if ( pWeapon )
        {
            if ( !pWeapon->GetPlayerOwner() )
            {
                UTIL_Remove( pCur );
            }
        }
        // remove entities that has to be restored on roundrestart (breakables etc)
        else if ( !FindInList( s_PreserveEnts, pCur->GetClassname() ) )
        {
            UTIL_Remove( pCur );
        }

        pCur = gEntList.NextEnt( pCur );
    }

    // Really remove the entities so we can have access to their slots below.
    gEntList.CleanupDeleteList();

    // Cancel all queued events, in case a func_bomb_target fired some delayed outputs that
    // could kill respawning CTs
    g_EventQueue.Clear();

    // Now reload the map entities.
    class CHL2MPMapEntityFilter : public IMapEntityFilter
    {
    public:
        virtual bool ShouldCreateEntity( const char *pClassname )
        {
            // Don't recreate the preserved entities.
            if ( !FindInList( s_PreserveEnts, pClassname ) )
            {
                return true;
            }
            else
            {
                // Increment our iterator since it's not going to call CreateNextEntity for this ent.
                if ( m_iIterator != g_MapEntityRefs.InvalidIndex() )
                    m_iIterator = g_MapEntityRefs.Next( m_iIterator );

                return false;
            }
        }


        virtual CBaseEntity* CreateNextEntity( const char *pClassname )
        {
            if ( m_iIterator == g_MapEntityRefs.InvalidIndex() )
            {
                // This shouldn't be possible. When we loaded the map, it should have used
                // CCSMapLoadEntityFilter, which should have built the g_MapEntityRefs list
                // with the same list of entities we're referring to here.
                Assert( false );
                return NULL;
            }
            else
            {
                CMapEntityRef &ref = g_MapEntityRefs[m_iIterator];
                m_iIterator = g_MapEntityRefs.Next( m_iIterator );	// Seek to the next entity.

                if ( ref.m_iEdict == -1 || engine->PEntityOfEntIndex( ref.m_iEdict ) )
                {
                    // Doh! The entity was delete and its slot was reused.
                    // Just use any old edict slot. This case sucks because we lose the baseline.
                    return CreateEntityByName( pClassname );
                }
                else
                {
                    // Cool, the slot where this entity was is free again (most likely, the entity was
                    // freed above). Now create an entity with this specific index.
                    return CreateEntityByName( pClassname, ref.m_iEdict );
                }
            }
        }

    public:
        int m_iIterator; // Iterator into g_MapEntityRefs.
    };
    CHL2MPMapEntityFilter filter;
    filter.m_iIterator = g_MapEntityRefs.Head();

    // DO NOT CALL SPAWN ON info_node ENTITIES!

    MapEntity_ParseAllEntities( engine->GetMapEntitiesString(), &filter, true );
}
Exemple #30
0
int GetThing(int *ad, int *no)
{
	char *a=WordPtr;	/* Save of */
	WLIST *b;
	WLIST *t;
	int posnoun=-1;
	char *backptr;
	*ad=-1;
l1:	backptr=WordPtr;
	b=GetWord();
	if(b==(WLIST *)-1)
	{
		WordPtr=a;
		return(-1);
	}
	if(b==NULL)
		goto l1;	/* Dud word */
	if(FindInList(WordList,WordBuffer,WD_PREP)&&
		FindInList(WordList,WordBuffer,WD_NOUN))
	{
		if(GetWord()==(WLIST *)-1)
		{
			WordPtr=backptr;
			b=GetWord();	/* Use noun */
		}
		else
		{
			WordPtr=backptr;
			*no= -1;
			return(-1);
		}
	}
	t=FindInList(WordList,WordBuffer,WD_PRONOUN);
	if(t)
	{
		ProLoad(t->wd_Code,ad,no);
		return(0);
	}
	if(FindInList(WordList,WordBuffer,WD_ADJ))
	{
		t=FindInList(WordList,WordBuffer,WD_ADJ);
		b=t;
	}
	else
		goto l2;
	t=FindInList(WordList,WordBuffer,WD_NOUN);
	if(t)
		posnoun=t->wd_Code;	/* It might still be noun */
	if(b)
		*ad=b->wd_Code;
l3:	a=WordPtr;
	b=GetWord();
	if(b==(WLIST *)-1)
	{
		WordPtr=a;
		if(posnoun)
		{
			*ad=-1;
			*no=posnoun;
			return(0);
		}
		return(-1);
	}
	if (b == NULL)
	{
		goto l3;	/* Dud word */
	}

l2:	b = FindInList(WordList, WordBuffer, WD_NOUN);
	if(!b)
	{
		WordPtr=a;
		if(posnoun!=-1)
		{
			*no=posnoun;	/* Adj/Noun clasher - noun form */
			*ad=-1;
			return(0);
		}
		if(!b)
			return(-1);
	}
	*no=b->wd_Code;
	return(0);
}