示例#1
0
void		Map::produceFood(Snake const *snake)
{
  int		ntry = 0;
  bool		state;
  int		x;
  int		y;

  srand(time(0));
  state = false;
  while (state == false && ntry < 1000)
    {
      x = rand() % (this->_height - 1) + 1;
      y = rand() % (this->_width - 1) + 1;
      state = true;
      if (getCase(x, y) != tEmpty)
	state = false;
      if (snake)
	{
	  for (std::list<SnakeElement *>::const_iterator it = snake->getList().begin(); it != snake->getList().end(); ++it)
	    {
	      if (x == (*it)->getPos()[0] && y == (*it)->getPos()[1])
		state = false;
	    }
	}
      ntry++;
    }
  if (ntry == 1000)
    throw MapException("Impossible to produce food.");
  setCase(x, y, tFood);
}
const TableSortField& TableSortField::operator=(const TableSortField& obj)
{
    if (this != &obj)
    {
        *m_comparer = *obj.m_comparer;
        setFieldIndex(obj.fieldIndex());
        setCase(obj.caseSensitivity());
        setSortOrder(obj.sortOrder());
        setFieldName(obj.fieldName());
        setFieldType(obj.fieldType());
    }
    return *this;
}
示例#3
0
BOOL AP_Win32Dialog_ToggleCase::_onCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
	WORD wId = LOWORD(wParam);

	switch (wId)
	{
	case IDCANCEL:						// also AP_RID_DIALOG_TOGGLECASE_BTN_CANCEL
		setAnswer(a_CANCEL);
		EndDialog(hWnd,0);
		return 1;

	case IDOK:							// also AP_RID_DIALOG_TOGGLECASE_BTN_OK
		setAnswer(a_OK);
		setCase(m_iWhichCase);
		EndDialog(hWnd,0);
		return 1;

	case AP_RID_DIALOG_TOGGLECASE_RDO_SentenceCase:
		m_iWhichCase = CASE_SENTENCE;
		return 1;

	case AP_RID_DIALOG_TOGGLECASE_RDO_LowerCase:
		m_iWhichCase = CASE_LOWER;
		return 1;
		
	case AP_RID_DIALOG_TOGGLECASE_RDO_UpperCase:
		m_iWhichCase = CASE_UPPER;
		return 1;
		
	case AP_RID_DIALOG_TOGGLECASE_RDO_TitleCase:
		m_iWhichCase = CASE_FIRST_CAPITAL;
		return 1;
		
	case AP_RID_DIALOG_TOGGLECASE_RDO_ToggleCase:
		m_iWhichCase = CASE_TOGGLE;
		return 1;

	default:							// we did not handle this notification
		UT_DEBUGMSG(("WM_Command for id %ld\n",wId));
		return 0;						// return zero to let windows take care of it.
	}
}
示例#4
0
int main()
{
  // Creation de la carte
  struct map* carte = newMap(MAP_W, MAP_H);

  // Initialisation de la map
  for(int i = 0; i < carte->height; ++i) {
    for(int j = 0; j < carte->width; ++j) {
      int tmp = i == 0 || j == 0 || i == carte->height-1 || j == carte->width-1;
      setCase(carte, i, j, tmp);
    }
  }

  // Affichage map
  printMap(carte);

  // On libère la map
  freeMap(carte);

  return EXIT_SUCCESS;
}
示例#5
0
void AddMailNotifyItem(LPFdirEntry lpFdirEntry, int type)
{
	char lpszText[10240];
	char szContributor[LEN_CIXNAME];
    char szFileName[LEN_CIXFILENAME];
	char szFileDate[64];
	char szFileSize[64];
	MAILOBJECT mailObject;
	LPFlistEntry lpFlistEntry;// = (LPFlistEntry)lpFdirEntry->fdirFlistEntry[0];
//	Context context = (Context)lpGlobals->context;

	if (lpFdirEntry->fdirFlistEntry[0] != NULL )
	{
		lpFlistEntry = (LPFlistEntry)lpFdirEntry->fdirFlistEntry[0];
	}
	lstrcpy( szContributor, "$CIX$" );
	GetRegistry((LPSTR)&szContributor);

	if(lstrcmp(lpGlobals->context.lpcConfName, "filepool") == 0)
		return;

	formatLong(szFileSize, "", lpFdirEntry->fdirSize, " bytes");
	strftime(szFileDate, 63, "%A %d %B %Y", localtime(&lpFdirEntry->fdirTimestamp));
    setCase(szFileName, lpFdirEntry->fdirName, setup.wNotifyCase);

	if (lpFdirEntry->fdirFlistEntry[0] != NULL )
	{
		wsprintf(lpszText, "\r\n"
					 " %s\r\n"
					 "\r\n"
					 "   Filename: %s\r\n"
					 "    Hotlink: cixfile:\r\n"
					 "  File size: %s\r\n"
					 "Contributor: %s\r\n"
					 "       Date: %s\r\n"
					 "%s"
					 "\r\n"
					 "Description: \r\n\r\n"
					 "%s\r\n",
					 type?"The following local file has been exported to the filepool:":"The following file has been exported to the filepool:",
				   (LPSTR)szFileName, 
				   (LPSTR)szFileSize,
				   (LPSTR)szContributor, 
				   (LPSTR)szFileDate,
				   setup.os_and_status?"     Status: \r\n        O/S: \r\n":"",
				   (LPSTR)lpFlistEntry->flistDescription);
	}
	else
	{
		wsprintf(lpszText, "\r\n"
					 " %s\r\n"
					 "\r\n"
					 "   Filename: %s\r\n"
					 "    Hotlink: cixfile:\r\n"
					 "  File size: %s\r\n"
					 "Contributor: %s\r\n"
					 "       Date: %s\r\n"
					 "%s"
					 "\r\n"
					 "Description: <Unknown>\r\n\r\n"
					 "\r\n",
					 type?"The following local file has been exported to the filepool:":"The following file has been exported to the filepool:",
				   (LPSTR)szFileName, 
				   (LPSTR)szFileSize,
				   (LPSTR)szContributor, 
				   (LPSTR)szFileDate,
				   setup.os_and_status?"     Status: \r\n        O/S: \r\n":"");
	}
	InitObject(&mailObject, OT_MAIL, MAILOBJECT);
	lstrcpy(mailObject.szTo, "*****@*****.**");
	lstrcpy(mailObject.szSubject, "Export To Filepool - ");
	lstrcat(mailObject.szSubject, szFileName);
	mailObject.szCC[0] = '\x0';
	mailObject.szReply[0] = '\x0';
	PutObject(NULL, &mailObject, lpszText);
}