Example #1
0
extern "C" BOOL WINAPI EXPORT _Run(HINSTANCE hInst, 
								   HWND hwndParent, 
								   LPBYTE *buffer, 
								   LONG *size)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	CWnd *pWnd = CWnd::FromHandle(hwndParent);

	CModParam param;
	VERIFY(param.SetBuffer(*buffer, *size));

	CWnd *pWnd1 = CWnd::FromHandle(GetTopWindow(NULL));

	if(param.GetValue(L"contrato").IsEmpty())
	{
		STLOG_WRITE(L"Tag contrato esta vazia");
		return FALSE;
	}

	CppSQLite3DB *pDB = CppSQLite3DB::getInstance();

	if(!pDB->isOpen())
	{
		pDB = NULL;
		STLOG_WRITE(L"_Run1: Database pointer is null.");
		return FALSE;
	}

	CString sCodigo = param.GetValue(L"codigo");

	CSincroDlg::m_wnd = CMsgWindow::getInstance();
	CSincroDlg::m_wnd->Create(pWnd1);
	CSincroDlg::m_wnd->Show(L"");
	CSincroDlg dlg(pDB, sCodigo, pWnd);
	dlg.m_params = &param;

	//dlg.m_sServer   = param.GetValue(L"server");
	//dlg.m_sContrato = param.GetValue(L"contrato"); 

	dlg.DoModal();

	// Se nao retorna parametro... OK...
	return FALSE;
}
bool PlayerInfoDataManager::init(){
    string path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("config/luckycat.sqlite");
    
    CppSQLite3DB db;
    db.open(path.c_str());
	if (!db.isOpen())
	{
		return false;
	}
    CppSQLite3Query q = db.execQuery("select * from dict_equipment;");
    while(!q.eof())
    {
        stActorUserEquipInfo  tempInfo;
        
        tempInfo.userEquipId = q.getIntField("id");
        tempInfo.userEquipType = q.getIntField("class");
        tempInfo.userPutOn = false;
        
        stActorEquipInfo equipInfo;// = new stActorEquipInfo();
        equipInfo.equipName = q.getStringField("name");
        equipInfo.equipImageId = q.getIntField("image_id");
        equipInfo.equipLife = q.getIntField("life");
        equipInfo.equipLevelLimit = q.getIntField("level_limit");
        equipInfo.equipAttack = q.getIntField("attack");
        equipInfo.equipDefence = q.getIntField("defence");
        equipInfo.equipSpeed = q.getIntField("speed");
        equipInfo.equipDescription = q.getStringField("description");
        
        tempInfo.equipInfo = &equipInfo;

        m_vecUserEquipInfos.push_back(tempInfo);
        
        q.nextRow();
    }
    
    return true;
}
void EventDataManager::readDB()
{
    string strFullPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("config/luckycat.sqlite");
    CppSQLite3DB db;
    db.open(strFullPath.c_str());
	if (!db.isOpen())
	{
		return;
	}
    
//    CppSQLite3Query result = db.execQuery("select * from dict_event;");
//    
//    std::vector<stEvent *> tEventVector;
//	while(!result.eof())
//	{
//        stEvent *tEvent = new stEvent();
//        tEvent->id = result.getIntField("id");
//        tEvent->type = (LEventType)result.getIntField("type");
//        tEvent->targetId = atoi(result.getStringField("target"));
//        std::string strBonus = result.getStringField("bonus");
//        std::vector<int> tmpBonusList = separateStringToNumberVector(strBonus, ",");
//        
//        if (tmpBonusList.size() > 0)
//            CCAssert( tmpBonusList[0]*2 == tmpBonusList.size()-1, "Something error in sql field\n");
//        for (int i = 1; tmpBonusList[0] != 0 && i+1 < tmpBonusList.size(); i+=2) {
//            stGood _good;
//            _good.id = tmpBonusList[i];
//            _good.count = tmpBonusList[i+1];
//            tEvent->bonus.push_back(_good);
//        }
//        
//        tEvent->bonusRepeat = result.getIntField("bonus_repeat");
//        tEvent->nextEventId = result.getIntField("next_event_id");
//        tEvent->box_id = result.getIntField("box_id");
//        
//        tEventVector.push_back(tEvent);
//        
//        result.nextRow();
//    }
//    
//    this->setEventMap(tEventVector);
    
    CppSQLite3Query result_1 = db.execQuery("select * from dict_npc_talk;");
    
    std::vector<stTalk *> tTalkVector;
	while(!result_1.eof())
	{
        stTalk *tTalk = new stTalk();
        tTalk->id = result_1.getIntField("id");
        tTalk->eventId = result_1.getIntField("event_id");
        std::string _dialog= result_1.getStringField("content");
        
        tTalk->dialogList = separateString(_dialog,"||");
        
        tTalk->npcId = result_1.getIntField("npc_id");
        tTalk->npcName = result_1.getStringField("npc_name");
        
        tTalkVector.push_back(tTalk);
        
        result_1.nextRow();
    }
    this->setTalkMap(tTalkVector);
    
    db.close();
}