Esempio n. 1
0
bool InCollectionSolver::SolveSquare(Coords coords)
{
  bool didSomething = false;
  Square * toSolve = _theBoard->GetSquare(coords);
  const vector<int> values = toSolve->Values();

  if (CheckIn(toSolve, _theBoard->GetCol(coords), coords.YCoord()))
  {
    _stats[ColToken]++;
    didSomething = true;
  }

  if (CheckIn(toSolve, _theBoard->GetRow(coords), coords.XCoord()))
  {
    _stats[RowToken]++;
    didSomething = true;
  }

  if (CheckIn(toSolve, _theBoard->GetArea(coords),
    _theBoard->IndexInAreaMap(coords)))
  {
    _stats[AreaToken]++;
    didSomething = true;
  }

  // Return whether we have managed to eliminate any possibilities
  return didSomething;
}
Esempio n. 2
0
node_idx Forest::Projection(level k, node_idx p, level * mask)
{
    Node *nodeP;
    node_idx result;
    node_idx flag;
    node_idx u;

    //Check Base Cases
    if (p == 0)
	return 0;

    if (k == 0)
	return 1;

    //Check Cache
    result = ProjectCache[k]->hit(p);
    if (result >= 0) {
	return result;
    }

    nodeP = &FDDL_NODE(k, p);

    if (mask[k] == 0) {
	flag = 0;
	for (node_idx i = 0; i < nodeP->size; i++) {
	    u = Projection(k - 1, FDDL_ARC(k, nodeP, i), mask);
	    flag = InternalMax(k - 1, u, flag);
	}
	if (flag != 0) {
	    result = NewNode(k);
	    for (node_idx i = 0; i <= maxVals[k]; i++) {
		SetArc(k, result, i, flag);
	    }
	    result = CheckIn(k, result);
	    ProjectCache[k]->add(result, p);
	    return result;
	}
    } else {
	result = NewNode(k);
	for (node_idx i = 0; i < nodeP->size; i++) {
	    SetArc(k, result, i,
		   Projection(k - 1, FDDL_ARC(k, nodeP, i), mask));
	}
	result = CheckIn(k, result);
	ProjectCache[k]->add(result, p);
	return result;
    }
    return 0;
}
Esempio n. 3
0
node_idx Forest::ProjectVals(level k, node_idx p, level cutoff)
{
    Node *nodeP;
    node_idx result;
    node_idx flag;

    //Check Base Cases
    if (p == 0)
	return 0;

    if (k == 0)
	return 1;

    //Check Cache
    result = ProjectCache[k]->hit(p);
    if (result >= 0) {
	return result;
    }

    nodeP = &FDDL_NODE(k, p);

    if (k < cutoff) {
	flag = 0;
	for (node_idx i = 0; i < nodeP->size; i++) {
	    flag = ProjectVals(k - 1, FDDL_ARC(k, nodeP, i), cutoff);
	    if (flag != 0)
		break;
	}
	if (flag != 0) {
	    result = NewNode(k);
	    for (node_idx i = 0; i <= maxVals[k]; i++) {
		SetArc(k, result, i, flag);
	    }
	    result = CheckIn(k, result);
	    ProjectCache[k]->add(result, p);
	    return result;
	}
    } else {
	result = NewNode(k);
	for (node_idx i = 0; i < nodeP->size; i++) {
	    SetArc(k, result, i,
		   ProjectVals(k - 1, FDDL_ARC(k, nodeP, i), cutoff));
	}
	result = CheckIn(k, result);
	ProjectCache[k]->add(result, p);
	return result;
    }
    return 0;
}
Esempio n. 4
0
FLEXlm::~FLEXlm(void)
{
   VOID *voidPtr = NULL;
   CString key;

   //check in any checked out licenses
   POSITION pos = m_jobMap.GetStartPosition();
   while (pos)
   {
      m_jobMap.GetNextAssoc(pos, key, voidPtr);
      CheckIn(key);
   }

   m_sErrMsg.Empty();

   // see if we need to save the license data
   if (!m_saLicsToCheck.IsEmpty() && m_bCreateLicList)
   {
      CString path = m_sCwd + m_sAvailLicFName;
      CStdioFile licFile;

      if (licFile.Open(path, CFile::modeCreate|CFile::modeWrite|CFile::typeText))
      {
         for (int i=0; i<m_saLicsToCheck.GetCount(); i++)
            licFile.WriteString(m_saLicsToCheck[i] + "\n");
      }
      licFile.Close();
   }

   //Free the memory associated with this job
   lc_free_job(m_lmJob);
}
void TcpClient::ConnectHandler(const system::error_code& ec,sock_pt sock)
{
	if(ec)
	{	
		PrintError(ec);
		if(ConnectionDisable(ec))
		{
			//m_PacketProcessor->ClientConnect(false);
			if (NULL != m_PacketProcessor)
			{
				m_PacketProcessor->ClientConnect(false);
				m_PacketProcessor->ClientConnect(m_site_info, false);
			}
			utility::wait_time(1000);
			Connect();
		}
	}
	else
	{
		//m_PacketProcessor->ClientConnect(true);
		if (NULL != m_PacketProcessor)
		{
			m_PacketProcessor->ClientConnect(true);
			m_PacketProcessor->ClientConnect(m_site_info, true);
		}
		CheckIn();
		read(m_rev_data,max_data_buffer);
	}
}
Esempio n. 6
0
void NetBase::ProcessNetwork (csTicks timeout)
{
    // Incoming packets from the wire go to a queue for processing by app.
    while (
        (SendOut() || CheckIn()
        // Outgoing packets from a queue go on the wire.
        ) && csGetTicks() <= timeout
        );
}
Esempio n. 7
0
/* Connect is designed to be run in a different thread as it only 
   exits if wiiremote is either disabled or a connection is made*/
bool CWiiRemote::Connect()
{
#ifndef _DEBUG
  cwiid_set_err(ErrorCallback);
#endif
  while (!m_connected)
  {
    g_Ping->Send(m_Socket, m_MyAddr);
    int flags = 0;
    ToggleBit(flags, CWIID_FLAG_MESG_IFC);
    ToggleBit(flags, CWIID_FLAG_REPEAT_BTN);

    m_wiiremoteHandle = cwiid_connect(&m_btaddr, flags);
    if (m_wiiremoteHandle != NULL)
    {
      SetupWiiRemote();
      // get battery state etc.
      cwiid_state wiiremote_state;
      int err = cwiid_get_state(m_wiiremoteHandle, &wiiremote_state);
      if (!err)
      {
        char Mesg[1024];
        sprintf(Mesg, "%i%% battery remaining", static_cast<int>(((float)(wiiremote_state.battery)/CWIID_BATTERY_MAX)*100.0));
        CPacketNOTIFICATION notification("Wii Remote connected", Mesg, ICON_PNG, g_BluetoothIconPath.c_str());
        notification.Send(m_Socket, m_MyAddr);
      }
      else
      {
        printf("Problem probing for status of WiiRemote; cwiid_get_state returned non-zero\n");
        CPacketLOG log(LOGNOTICE, "Problem probing for status of WiiRemote; cwiid_get_state returned non-zero");
        log.Send(m_Socket, m_MyAddr);
        CPacketNOTIFICATION notification("Wii Remote connected", "", ICON_PNG, g_BluetoothIconPath.c_str());
        notification.Send(m_Socket, m_MyAddr);
      }
#ifdef CWIID_OLD
      /* CheckIn to say that this is the last msg, If this isn't called it could give issues if we Connects -> Disconnect and then try to connect again 
         the CWIID_OLD hack would automaticly disconnect the wiiremote as the lastmsg is too old. */
      CheckIn();
#endif      
      m_connected = true;

      CPacketLOG log(LOGNOTICE, "Sucessfully connected a WiiRemote");
      log.Send(m_Socket, m_MyAddr);
      return true;
    }
    //Here's a good place to have a quit flag check...

  }
  return false;
}
Esempio n. 8
0
node_idx Forest::InternalRestrict(level k, node_idx p, node_idx q)
{
    //Easy Terminal Cases
    if (p == 0 || p == q)
	return q;
    if (q == 0)
	return p;
    if (k == 0)
	return q;

    //Check for an entry in the Cache.
    node_idx result;

    result = RestrictCache[k]->hit(p, q);
    if (result >= 0) {
	if (!(FDDL_NODE(k, result).flags & FLAG_DELETED))
	    return result;
	if (garbage_alg != O_STRICT)
	    return CheckIn(k, result);
    }

    result = NewNode(k);	//result initially has size 0.
    Node *nodeP = &FDDL_NODE(k, p);
    Node *nodeQ = &FDDL_NODE(k, q);

    int psize = nodeP->size;
    int qsize = nodeQ->size;

    //If neither node is sparse, do things the easy way.
    if (!IS_SPARSE(nodeP) && !IS_SPARSE(nodeQ)) {
	for (arc_idx i = 0; i < (psize > qsize ? psize : qsize); i++) {
	    node_idx
		u = InternalRestrict(k - 1,
				     i < psize ? FULL_ARC(k, nodeP, i) : 0,
				     i < qsize ? FULL_ARC(k, nodeQ,
							  i) : 0);

	    SetArc(k, result, i, u);
	}
    } else if (IS_SPARSE(nodeP) && IS_SPARSE(nodeQ)) {
	//If both nodes are sparse, do things the fast way!
	//Scan from left to right.  If i is the smaller value, put it in the
	//node.  If j is the smaller value, put it in the node.  If i==j, put
	//the union of i and j in the node.  

	for (arc_idx i = 0, j = 0; i < psize || j < qsize;) {
	    arc_idx pdx = SPARSE_INDEX(k, nodeP, i);
	    node_idx pval = SPARSE_ARC(k, nodeP, i);
	    arc_idx qdx = SPARSE_INDEX(k, nodeQ, j);
	    node_idx qval = SPARSE_ARC(k, nodeQ, j);

	    if (i >= psize) {
		SetArc(k, result, qdx, qval);
		j++;
	    } else if (j >= qsize) {
		SetArc(k, result, pdx, pval);
		i++;
	    } else if (pdx < qdx) {
		SetArc(k, result, pdx, pval);
		i++;
	    } else if (qdx < pdx) {
		SetArc(k, result, qdx, qval);
		j++;
	    } else {
		SetArc(k, result, pdx,
		       InternalRestrict(k - 1, pval, qval));
		i++;
		j++;
	    }
	}
    } else {
	if (IS_SPARSE(nodeP) && !IS_SPARSE(nodeQ)) {
	    int j = 0;

	    for (int i = 0; i < nodeP->size || j < nodeQ->size;) {
		int idx = SPARSE_INDEX(k, nodeP, i);
		int ival = SPARSE_ARC(k, nodeP, i);
		int jval = FULL_ARC(k, nodeQ, j);

		if (i >= nodeP->size) {
		    SetArc(k, result, j, jval);
		    j++;
		} else if (j >= nodeQ->size) {
		    SetArc(k, result, idx, ival);
		    i++;
		} else if (j < idx) {
		    SetArc(k, result, j, jval);
		    j++;
		} else if (idx < j) {
		    SetArc(k, result, idx, ival);
		    i++;
		} else {
		    SetArc(k, result, j,
			   InternalRestrict(k - 1, ival, jval));
		    i++;
		    j++;
		}
	    }
	} else if (IS_SPARSE(nodeQ) && !IS_SPARSE(nodeP)) {
	    int j = 0;

	    for (int i = 0; i < nodeP->size || j < nodeQ->size;) {
		int jdx = SPARSE_INDEX(k, nodeQ, j);
		int jval = SPARSE_ARC(k, nodeQ, j);
		int ival = FULL_ARC(k, nodeP, i);

		if (i >= nodeP->size) {
		    SetArc(k, result, jdx, jval);
		    j++;
		} else if (j >= nodeQ->size) {
		    SetArc(k, result, i, ival);
		    i++;
		} else if (i < jdx) {
		    SetArc(k, result, i, ival);
		    i++;
		} else if (jdx < i) {
		    SetArc(k, result, jdx, jval);
		    j++;
		} else {
		    SetArc(k, result, i,
			   InternalRestrict(k - 1, ival, jval));
		    i++;
		    j++;
		}
	    }

	}
    }

    node_idx newresult = CheckIn(k, result);

//  if (k > 0 && newresult)
//    FDDL_NODE (k, newresult).flags |= FLAG_CHECKED_IN;
    RestrictCache[k]->add(newresult, p, q);
    return newresult;
}
Esempio n. 9
0
SHORT FLEXlm::InitFLEXlm(CString exePath, CString availableLicsFileName, VOID *funcPtr)
{
   if (m_bIsInitialized) return RET_NO_ERROR;

   {
      //Make sure the registry entry for the license file exists (Did the user configure the license file?)
      HKEY flexKey = NULL;
      LONG result = 0;
      result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\FLEXlm License Manager", 0, KEY_QUERY_VALUE, &flexKey);
      if (result != ERROR_SUCCESS)
      {
         LPVOID lpMsgBuf;
         FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
            NULL, result, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL);

         m_sErrMsg = NO_LICMGR_S + "\n\n" + (LPCTSTR)lpMsgBuf;

         // Free the buffer.
         LocalFree( lpMsgBuf );
         return RET_INVALID_PARAM;
      }

      const int licPathSize = 64;  // This allows a successful RegQueryValueEx() when executing a Release Build with debug info and optimization. (knv)
      char licPath[licPathSize];
      DWORD bufLen = licPathSize;
      result = RegQueryValueEx(flexKey, "RSI_LM_LICENSE_FILE", NULL, NULL, (LPBYTE)licPath, &bufLen);
      if ((result == ERROR_SUCCESS && strlen(licPath) <= 0) || (result != ERROR_SUCCESS && result != ERROR_MORE_DATA))
      {
         LPVOID lpMsgBuf;
         FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
            NULL, result, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL);

         m_sErrMsg = NOT_CONFIG_S + "\n\n" + (LPCTSTR)lpMsgBuf;

         // Free the buffer.
         LocalFree( lpMsgBuf );
         return RET_INVALID_PARAM;
      }

      RegCloseKey(flexKey);
   }

   if (!m_bLicsAreGood) return RET_NO_LIC;

   SHORT result = 0;

   m_sErrMsg.Empty();
   flexObj = this;
   m_bUseLog = m_bCreateLicList = FALSE;
   m_saLicsToCheck.RemoveAll();

   m_sCwd = exePath;
   m_sAvailLicFName = availableLicsFileName;

   VOID *voidPtr = NULL;
   CString key;

   //check in any checked out licenses
   POSITION pos = m_jobMap.GetStartPosition();
   while (pos)
   {
      m_jobMap.GetNextAssoc(pos, key, voidPtr);
      CheckIn(key);
   }

   readLicAvailablity();

   gExitFuncPtr = (FUNCPTR*)funcPtr;
   result = lc_set_attr(m_lmJob, LM_A_USER_EXITCALL, (LM_A_VAL_TYPE)OnFLEXlmExitCall);
   result = lc_set_attr(m_lmJob, LM_A_CHECKOUTFILTER, (LM_A_VAL_TYPE)OnCheckOutFilter);
   result = lc_set_attr(m_lmJob, LM_A_CHECK_INTERVAL, (LM_A_VAL_TYPE)30);
   result = lc_set_attr(m_lmJob, LM_A_RETRY_INTERVAL, (LM_A_VAL_TYPE)30);
   result = lc_set_attr(m_lmJob, LM_A_PROMPT_FOR_FILE, (LM_A_VAL_TYPE)FALSE);

   m_bIsInitialized = TRUE;
   return RET_NO_ERROR;
}
Esempio n. 10
0
//Alters the map to the users specifications
void Map::AlterMap (char W, char S, char F, char G, char C, char X, char L, char E, char P)
{
	if (Washrooms(W))
	{
		floorOne[3][3] = 'W'; floorOne[2][11] = 'W'; floorOne[13][45] = 'W'; floorOne[13][51] = 'W';
		floorTwo[13][4] = 'W'; floorTwo[13][12] = 'W'; floorTwo[2][50] = 'W'; floorTwo[5][50] = 'W';
	} else
	{
		floorOne[3][3] = ' '; floorOne[2][11] = ' '; floorOne[13][45] = ' '; floorOne[13][51] = ' ';
		floorTwo[13][4] = ' '; floorTwo[13][12] = ' '; floorTwo[2][50] = ' '; floorTwo[5][50] = ' ';
	}

	if (Store(S))
	{
		floorOne[11][4] = 'S';
		floorTwo[8][3] = 'S';
	} else
	{
		floorOne[11][4] = ' ';
		floorTwo[8][3] = ' ';
	}

	if (Food(F))
	{
		floorTwo[2][4] = 'F'; floorTwo[2][12] = 'F';
	} else
	{
		floorTwo[2][4] = ' '; floorTwo[2][12] = ' ';
	}

	if (Gate(G))
	{
		floorTwo[1][27] = 'G'; floorTwo[1][40] = 'G';
	} else
	{
		floorTwo[1][27] = ' '; floorTwo[1][40] = ' ';
	}

	if (Customs(C))
	{
		floorTwo[9][31] = 'C';
	} else
	{
		floorTwo[9][31] = ' ';
	}

	if (CheckIn(X))
	{
		floorOne[2][38] = 'X';
	} else
	{
		floorOne[2][38] = ' ';
	}

	if (Luggage(L))
	{
		floorOne[2][38] = 'L';
	} else
	{
		floorOne[2][38] = ' ';
	}

	if (Entrance(E))
	{
		floorOne[10][52] = 'E';
	} else
	{
		floorOne[10][52] = ' ';
	}

	if (PickUp(P))
	{
		floorOne[11][28] = 'P'; floorOne[11][37] = 'P';
	} else
	{
		floorOne[11][28] = ' '; floorTwo[11][37] = ' ';
	}
}
Esempio n. 11
0
void CEntityCheckInComponent::OnCheck(GameMsg_Base &msg, CSlotPeer &slotPeer)
{
    ResetByMonthChange();

    GameMsg_C2S_Check & c2smsg = (GameMsg_C2S_Check&)msg;
    int nError = CheckIn(c2smsg.m_nDayIndex);
    if (nError != ECheckInErrorMsg_Success)
    {
        GameMsg_S2C_CheckInFail failmsg;
        failmsg.m_nFailFlag = nError;
        SendPlayerMsg(&failmsg);
    }
    else
    {
        GameMsg_S2C_CheckInSuccess sucmsg;
        sucmsg.m_nDayIndex = c2smsg.m_nDayIndex;
        CCheckInConfig * pCheckInConfig = CCheckInDataManager::Instance().GetCheckInConfig(c2smsg.m_nDayIndex);
        if (pCheckInConfig != NULL)
        {
            int nVipRate = 1;
            if (m_pRoleVip->IsVIP() && m_pRoleVip->VIPLevel() >= (int)pCheckInConfig->m_nVipRewardLevel
                && pCheckInConfig->m_nVipRewardLevel > 0)
            {
                nVipRate = pCheckInConfig->m_nVipRewardRate;
            }

            sucmsg.m_nMoney = pCheckInConfig->m_nMoney*nVipRate;
            sucmsg.m_nBindCoin = pCheckInConfig->m_nBindCoin*nVipRate;
            sucmsg.m_ItemReward = m_pRoleAttr->GetSex() == ESexType_Male ? pCheckInConfig->m_maleItemReward : pCheckInConfig->m_femaleItemReward;

            if (m_pRoleAttr->GetSex() == ESexType_Male)
            {
                CItem maleitem(pCheckInConfig->m_maleItemReward);
                ItemConfig * pItemInfo = ConfigManager::Instance().GetItemConfigManager().GetByID(pCheckInConfig->m_maleItemReward.m_nItemType);
                if (pItemInfo != NULL)
                {
                    if (pItemInfo->IsEquip())
                    {
                        if (nVipRate > 1)
                        {
                            maleitem.m_nValidTime = -1;
                        }
                    }
                    else
                    {
                        maleitem.m_nItemCount = (itemcount_t)(maleitem.m_nItemCount*nVipRate);
                    }
                    sucmsg.m_ItemReward = maleitem;
                }
            }
            else
            {
                CItem femaleitem(pCheckInConfig->m_femaleItemReward);
                ItemConfig * pItemInfo = ConfigManager::Instance().GetItemConfigManager().GetByID(pCheckInConfig->m_femaleItemReward.m_nItemType);
                if (pItemInfo != NULL)
                {
                    if (pItemInfo->IsEquip())
                    {
                        if (nVipRate > 1)
                        {
                            femaleitem.m_nValidTime = -1;
                        }
                    }
                    else
                    {
                        femaleitem.m_nItemCount = (itemcount_t)(femaleitem.m_nItemCount*nVipRate);
                    }

                    sucmsg.m_ItemReward = femaleitem;
                }
            }
        }
        SendPlayerMsg(&sucmsg);

        // 通知其它系统
        CommonParam param;
        param.SetParam(std::string("activeness"), std::string("checkin"));
        NotifyAll(param);
    }
}