//-------------------------------------------------------------------------------------------- // MG_CN_MODIFY MG::Bool BigMapResCsv::load( Str16 fileName, IMGExternalPackManager* packManager/* = NULL */) { CsvReader csvreader; // MG_CN_MODIFY if(!csvreader.create(fileName, packManager)) { return false; } CsvData* csvdata = NULL; Int RowCount = csvreader.count(); for(int i = 0; i < RowCount; ++i) { csvdata = csvreader.findValue(i); if(!csvdata) { continue; } UInt nCol = 3; std::string widgetName; MGStrOp::toString(csvdata->mData[nCol++].c_str(), widgetName); UInt placeid = 0; MGStrOp::toU32(csvdata->mData[nCol++].c_str(), placeid ); mMapWidgetNamePlaceId[widgetName] = placeid; } return true; }
//----------------------------------------------------------------------------------- // MG_CN_MODIFY MG::Bool CharacterResourceConfig::load( Str16 fileName, IMGExternalPackManager* packManager/* = NULL*/ ) { CsvReader csvreader; // MG_CN_MODIFY if(!csvreader.create(fileName, packManager)) { return false; } CsvData* csvdata = NULL; Int RowCount = csvreader.count(); for(int i = 0; i < RowCount; ++i) { csvdata = csvreader.findValue(i); if(!csvdata) { continue; } CharacterResInfo* res_info = new CharacterResInfo(); MGStrOp::toU32(csvdata->mData[CHARACTER_ID].c_str(),res_info->id); MGStrOp::toU32(csvdata->mData[CHARACTER_TEMPLATEID].c_str(),res_info->templateid); res_info->name = csvdata->mData[CHARACTER_NAME].c_str(); MGStrOp::toU32(csvdata->mData[CHARACTER_MAPLISTID].c_str(),res_info->maplistid); MGStrOp::toU32(csvdata->mData[CHARACTER_POINTRESId].c_str(),res_info->pointresid); MGStrOp::toI32(csvdata->mData[CHARACTER_MAPLISTTYPE].c_str(),(I32&)res_info->maplisttype); mCharacterResourceList[res_info->id] = res_info; } return true; }
//Load Document BOOL LoadCSV(const TCHAR * filepath){ int ret = DialogAskTitle(); if (ret == IDYES) csvReader.open(filepath,1); else csvReader.open(filepath); return TRUE; }
Schedule Schedule::fromOutlookCsvData(const QString& dataString, const QTimeZone& timeZone, const QString& dateFormat, const QString& timeFormat) { CsvReader reader; reader.setData(dataString); QList<QStringList> parsedCsv = reader.parse(); return Schedule::fromOutlookCsvParsed(parsedCsv, timeZone, dateFormat, timeFormat); }
//------------------------------------------------------------------------------------------------------- // MG_CN_MODIFY MG::Bool CharacterNpcList::loadFile( Str16 filename, IMGExternalPackManager* packManager/* = NULL*/ ) { CsvReader csvreader; // MG_CN_MODIFY if(!csvreader.create(filename, packManager)) { return false; } CsvData* csvdata = NULL; Int RowCount = csvreader.count(); for(int i = 0; i < RowCount; ++i) { csvdata = csvreader.findValue(i); if(!csvdata) { continue; } CharacterNpcInfo* tempCharInfo = new CharacterNpcInfo; UInt nCol = 0; MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->CharacterNpcId); nCol++; tempCharInfo->ListName = csvdata->mData[nCol++].c_str(); tempCharInfo->SurName = csvdata->mData[nCol++].c_str(); tempCharInfo->Name = csvdata->mData[nCol++].c_str(); tempCharInfo->Title = csvdata->mData[nCol++].c_str(); tempCharInfo->Tips = csvdata->mData[nCol++].c_str(); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), (U32&)tempCharInfo->GenderType ); DYNAMIC_ASSERT(tempCharInfo->GenderType < GENDER_TYPE_MAX && tempCharInfo->GenderType > GENDER_TYPE_NULL); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->Level ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->CharacterAppellationId ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->CharacterDialogId ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->AIId ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->InfluenceId ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->ArtIconId ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->ArtMashId ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->ArtEffectId ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->CharacterVisionEventListId ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->AIBaseGroupId ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->AIFightGroupId ); mMapCharacterNpcInfo[tempCharInfo->CharacterNpcId] = tempCharInfo; } return true; }
//-------------------------------------------------------------------------- // MG_CN_MODIFY Bool DistrictListCsv::loadCsv(const Char16* FileName, IMGExternalPackManager* packManager/* = NULL*/) { CsvReader csvreader; // MG_CN_MODIFY if(!csvreader.create(FileName, packManager)) { return false; } CsvData* csvdata = NULL; Int RowCount = csvreader.count(); for(Int i = 0; i < RowCount; ++i) { csvdata = csvreader.findValue(i); if(!csvdata) { continue; } DistrictIdType id; MGStrOp::toI32(csvdata->mData[DistrictListRow::districtId].c_str(), id); if (true == isInDistrictList(id)) { DYNAMIC_ASSERT(0); continue; } I32 openType = -1; MGStrOp::toI32(csvdata->mData[DistrictListRow::openType].c_str(), openType); if (DOT_OPEN != (DistrictOpenType)openType) { continue; } DistrictListCsvInfo* newDistrictInfo = mDistrictList.createOrRetrieve(id, false); newDistrictInfo->setDistrictId(id); newDistrictInfo->setName(csvdata->mData[DistrictListRow::name]); newDistrictInfo->setText(csvdata->mData[DistrictListRow::text]); newDistrictInfo->setTitle(csvdata->mData[DistrictListRow::title]); newDistrictInfo->setOpenType((DistrictOpenType)openType); I32 rank = -1; MGStrOp::toI32(csvdata->mData[DistrictListRow::districtRank].c_str(), rank); newDistrictInfo->setRank((DistrictRankType)rank); int kk = 0; } return true; }
bool Data_EnemyDraw::LoadDataFromCsv(){ // リストの解放 drawList.Release(); // Csvを読み込むクラス CsvReader reader; // ファイル名を保持する TCHAR fileName[MAX_PATH]; // グループの内容を一時的に保持する変数 Data_EnemyDraw_Data tmpDraw; strcpy_s(fileName, MAX_PATH-1, CSVFILE_ENEMYDRAW); if(reader.Open(fileName)){ // ダミー行 reader.NextLine(); // csvファイルを読み込んでグループに格納する for(int n=0; n<MAX_ENEMYDRAWFILE; n++){ tmpDraw = DATA_ENEMYDRAW_DATA(); // レファレンス用IDを取得する if(reader.Read() == CSV_READ_NOERROR){ if(reader.GetIntValue(1, 0) == 0){ continue; } tmpDraw.refID = (WORD)reader.GetIntValue(1, 0); // 画像サイズを取得 tmpDraw.iWidth = reader.GetIntValue(2, 1); tmpDraw.iHeight = reader.GetIntValue(3, 1); // 描画基準位置を取得 tmpDraw.cx = reader.GetFloatValue(4, 0); tmpDraw.cy = reader.GetFloatValue(5, 0); // 拡大倍率を取得 tmpDraw.baseExRate = reader.GetFloatValue(6, 1.0); // 取得したグループをデータベースにセットする drawList.AddData(tmpDraw); } } }else{ return false; } // 画像ハンドルの結びつけは毎回手動で行う必要がある DATA_ENEMYDRAW_DATA* pData; for(int n=0; n<drawList.GetSize(); n++){ pData = drawList.GetPointerByIndex(n); for(int i=0; i<DOLL_ATTR_NUM; i++){ pData->hImg[i] = GetImgHandleByRefID(pData->refID, i); } } return true; }
void evaluateTestData(const Network& net) { CsvReader reader; CsvWriter writer; cout << "Leyendo test data" << endl; MatrixXd testData = reader.csvReadToMatrix(TEST_DATA_FILE); if (testData.rows() == 0 && testData.cols() == 0) { printf("Error leyendo test data.\n"); return; } cout << "cantidad de features: " << (testData.cols() - 1) << endl << endl; cout << "Evaluando test data" << endl; MatrixXd results = net.evaluate(testData); writer.makeSubmitWithMatrix(SUBMIT_FILE, results); }
//Display the openfile common dialog BOOL OpenSaveDialog(HWND hwnd){ OPENFILENAME ofn; TCHAR szFile[MAX_PATH]; ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.lpstrFile = szFile; ofn.lpstrFile[0] = '\0'; ofn.hwndOwner = hwnd; ofn.nMaxFile = sizeof(szFile); ofn.lpstrFilter = TEXT("EXCEL csv files(*.csv)\0*.csv\0"); ofn.nFilterIndex = 1; ofn.lpstrInitialDir = NULL; ofn.lpstrFileTitle = _T("123.csv"); ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; wstring s1, s2; if (GetSaveFileName(&ofn)){ s1 += L"正在保存:"; s2 += ofn.lpstrFile; s1 += s2; SendMessage((HWND)GetWindowLongPtr(hWnd, GWLP_USERDATA), SB_SETTEXT, 1, (LPARAM)s1.c_str()); SaveCSV(ofn.lpstrFile); } std::wostringstream s; s << L"已经保存" << s2 << " " << L"共保存了" << csvReader.getRowCount() << L"条"; wstring r(s.str()); SendMessage((HWND)GetWindowLongPtr(hWnd, GWLP_USERDATA), SB_SETTEXT, 0, (LPARAM)L"编辑中"); SendMessage((HWND)GetWindowLongPtr(hWnd, GWLP_USERDATA), SB_SETTEXT, 1, (LPARAM)r.c_str()); return TRUE; }
//----------------------------------------------------------------------------------- // MG_CN_MODIFY MG::Bool ColorResConfig::load( Str16 fileName, IMGExternalPackManager* packManager/* = NULL*/) { CsvReader csvreader; // MG_CN_MODIFY if(!csvreader.create(fileName, packManager)) { return false; } CsvData* csvdata = NULL; Int RowCount = csvreader.count(); for(int i = 0; i < RowCount; ++i) { csvdata = csvreader.findValue(i); if(!csvdata) { continue; } ColorResCsvInfo* tempInfo = new ColorResCsvInfo; UInt nCol = 0; MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempInfo->ColorRes_Id ); nCol++; MGStrOp::toString(csvdata->mData[nCol++].c_str(), tempInfo->ColorName ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), (U32&)tempInfo->UseType ); Str16 tempStr = csvdata->mData[nCol++]; MGStrOp::toFlt(tempStr.substr(0,3).c_str(),(tempInfo->ColorValue).r); MGStrOp::toFlt(tempStr.substr(3,3).c_str(),(tempInfo->ColorValue).g); MGStrOp::toFlt(tempStr.substr(6,3).c_str(),(tempInfo->ColorValue).b); MGStrOp::toFlt(tempStr.substr(9,3).c_str(),(tempInfo->ColorValue).a); tempInfo->ColorValue.r = tempInfo->ColorValue.r/255.0f; tempInfo->ColorValue.g = tempInfo->ColorValue.g/255.0f; tempInfo->ColorValue.b = tempInfo->ColorValue.b/255.0f; tempInfo->ColorValue.a = tempInfo->ColorValue.a/255.0f; MGStrOp::toString(csvdata->mData[nCol++].c_str(), tempInfo->EscapeChar); mColorResCsvMap[tempInfo->ColorRes_Id] = tempInfo; } return true; }
//Display the openfile common dialog BOOL OpenDialog(HWND hwnd){ OPENFILENAME ofn; TCHAR szFile[MAX_PATH]; ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.lpstrFile = szFile; ofn.lpstrFile[0] = '\0'; ofn.hwndOwner = hwnd; ofn.nMaxFile = sizeof(szFile); ofn.lpstrFilter = TEXT("EXCEL csv files(*.csv)\0*.csv\0"); ofn.nFilterIndex = 1; ofn.lpstrInitialDir = NULL; ofn.lpstrFileTitle = NULL; ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; wstring s1, s2; if (GetOpenFileName(&ofn)){ s1 += L"正在打开:"; s2 += ofn.lpstrFile; s1 += s2; SendMessage((HWND)GetWindowLongPtr(hWnd, GWLP_USERDATA), SB_SETTEXT, 1, (LPARAM)s1.c_str()); LoadCSV(ofn.lpstrFile); } std::wostringstream s; s << L"已经打开了" << s2 << " " << L"共读取了" << csvReader.getRowCount() << L"条"; wstring r(s.str()); SendMessage((HWND)GetWindowLongPtr(hWnd, GWLP_USERDATA), SB_SETTEXT, 0, (LPARAM)L"编辑中"); SendMessage((HWND)GetWindowLongPtr(hWnd, GWLP_USERDATA), SB_SETTEXT, 1, (LPARAM)r.c_str()); SetScrollRange(hwnd, SB_VERT, 0, csvReader.getRowCount(), FALSE); const int columnCount = csvReader.getHeadRow()->getColumnSize(); HMENU hmRand = GetSubMenu(hMenu, 1); assert(hmRand != NULL); for (int i = 0; i < columnCount; i++){ wstring s(L"以“"); s += csvReader.getHeadRow()->getColumn(i); s += L"”随机排序"; AppendMenu(hmRand, MF_STRING, IDM_RANDOMSORT_ITEM_1 + i,s.c_str()); } SetMenu(hWnd, hMenu); GetSystemMenu(hWnd, TRUE); return TRUE; }
//-------------------------------------------------------------------------- // MG_CN_MODIFY Bool RelationCsvBase::load(const Char16* FileName, IMGExternalPackManager* packManager/* = NULL*/) { CsvReader csvreader; // MG_CN_MODIFY if(!csvreader.create(FileName, packManager)) { return false; } CsvData* csvdata = NULL; Int RowCount = csvreader.count(); for(Int i = 0; i < RowCount; ++i) { csvdata = csvreader.findValue(i); if(!csvdata) { continue; } RelationIdType relationId; MGStrOp::toI32(csvdata->mData[RCB_RelationId].c_str(), relationId); if (true == mRelationList.hasData(relationId)) { DYNAMIC_ASSERT(0); continue; } MapIdType mapId; MGStrOp::toU32(csvdata->mData[RCB_MapId].c_str(), mapId); GameObjectIdType gameDataId; MGStrOp::toU64(csvdata->mData[RCB_GameDataId].c_str(), gameDataId); RelationInfo* newRelationInfo = mRelationList.createOrRetrieve(relationId, false); newRelationInfo->relationId = relationId; newRelationInfo->mapId = mapId; newRelationInfo->artName = csvdata->mData[RCB_ArtName]; newRelationInfo->gameDataId = gameDataId; //mArtMapResList[id] = newArtMapRes; } return true; }
// MG_CN_MODIFY MG::Bool QuestValueChangeInfos::load(Str16 fileName, IMGExternalPackManager* packManager/* = NULL*/) { CsvReader csvreader; // MG_CN_MODIFY if(!csvreader.create(fileName, packManager)) { return false; } CsvData* csvdata = NULL; Int rowCount = csvreader.count(); for(Int i = 0; i < rowCount; ++i) { csvdata = csvreader.findValue(i); if(!csvdata) { continue; } QuestValueChangeInfo* tempInfo = MG_NEW QuestValueChangeInfo; MGStrOp::toU32(csvdata->mData[questvaluechangeinfoid].c_str(), tempInfo->id); MGStrOp::toU32(csvdata->mData[questvaluechangeinfogroupid].c_str(), tempInfo->groupId); I32 tempType; MGStrOp::toI32(csvdata->mData[questvaluechangeinfotype].c_str(), tempType); tempInfo->type = (CHANGE_TYPE)tempType; MGStrOp::toU32(csvdata->mData[questvaluechangeinfoparam1].c_str(), tempInfo->param1); MGStrOp::toU32(csvdata->mData[questvaluechangeinfoparam2].c_str(), tempInfo->param2); MGStrOp::toU32(csvdata->mData[questvaluechangeinfoparam3].c_str(), tempInfo->param3); MGStrOp::toU32(csvdata->mData[questvaluechangeinfoparam4].c_str(), tempInfo->param4); MGStrOp::toI32(csvdata->mData[questvaluechangeinfovaluechangetype].c_str(), tempType); tempInfo->valueChangeType = (VALUECHANGE_TYPE)(tempType-1); //Мо±нґУ1їЄКј MGStrOp::toI32(csvdata->mData[questvaluechangeinfovaluechangenum].c_str(), tempInfo->valueChangeNum); if (getQuestValueChangeInfo(tempInfo->id)) { DYNAMIC_ASSERT(false); MG_SAFE_DELETE(tempInfo); continue; } mQuestValueChangeInfoMap[tempInfo->id] = tempInfo; } return true; }
Network trainNetWithParsedTrainData(vector<int> hiddenLayers, int epochs, int miniBatchSize, double learningRate, double regularizationFactor) { inputData_t data = generateInputData(); int input_dim = data.x_train.cols(); int output_dim = OUTPUT_SIZE; vector<int> layers; layers.push_back(input_dim); layers.insert(layers.end(), hiddenLayers.begin(), hiddenLayers.end()); //inserta todos los elementos de hiddenLayers layers.push_back(output_dim); Network net(layers); if (LOAD_NET){ CsvReader reader; vector<MatrixXd> weights = reader.readWheights(WEIGHTS_BASE_LOAD_PATH,2); vector<VectorXd> biases = reader.readBiases(BIASES_LOAD_PATH); net = Network(layers,biases,weights); } if (TRAIN_NET){ cout << "Arranca train" << endl; net.SGD(data.x_train, data.y_train, data.x_test, data.y_test, epochs, miniBatchSize, learningRate, regularizationFactor); } int validationResult = net.accuracy(data.x_validation, data.y_validation); double cost = net.totalCost(data.x_validation, data.y_validation); cout << "---------------------------" << endl; cout << "Validation results: " << validationResult << " / " << data.y_validation.rows() << endl; cout << "---------------------------" << endl; cout << "Validation cost: " << cost << endl; cout << "---------------------------" << endl; return net; }
//-------------------------------------------------------------------------- // MG_CN_MODIFY Bool ArtMapResCsv::load(const Char16* FileName, IMGExternalPackManager* packManager/* = NULL*/) { CsvReader csvreader; // MG_CN_MODIFY if(!csvreader.create(FileName, packManager)) { return false; } DYNAMIC_ASSERT(csvreader.getColumnSize() == AMR_RPGRadarID + 1 || csvreader.getColumnSize() == AMR_Max); CsvData* csvdata = NULL; Int RowCount = csvreader.count(); for(Int i = 0; i < RowCount; ++i) { csvdata = csvreader.findValue(i); if(!csvdata) { continue; } ArtMapResIdType artMapResId; MGStrOp::toI32(csvdata->mData[AMR_ArtMapResId].c_str(), artMapResId); if (true == mArtMapResList.hasData(artMapResId)) { DYNAMIC_ASSERT(0); continue; } ArtMapResCsvInfo* newArtMapRes = mArtMapResList.createOrRetrieve(artMapResId, false); newArtMapRes->artMapResId = artMapResId; newArtMapRes->name = csvdata->mData[AMR_Name]; newArtMapRes->BaseFilePath = csvdata->mData[AMR_BaseFilePath]; //newArtMapRes->cameraId = csvdata->mData[AMR_CameraSetID]; MGStrOp::toI32(csvdata->mData[AMR_UseType].c_str(), (I32&)newArtMapRes->mapType); MGStrOp::toU32(csvdata->mData[AMR_RPGCamSetID].c_str(), newArtMapRes->rpgCameraId); MGStrOp::toU32(csvdata->mData[AMR_RPGRadarID].c_str(), newArtMapRes->rpgRadarId); if ( csvdata->mData.size() > AMR_RPGRadarID + 1 ) { MGStrOp::toU32(csvdata->mData[AMR_SLGCamSetID].c_str(), newArtMapRes->slgCameraId); MGStrOp::toU32(csvdata->mData[AMR_SLGRadarID].c_str(), newArtMapRes->slgRadarId); } else { newArtMapRes->slgCameraId = newArtMapRes->rpgCameraId; newArtMapRes->slgRadarId = newArtMapRes->rpgRadarId; } } return true; }
//------------------------------------------------------------------------------------------- // MG_CN_MODIFY Bool LongRangeGeneralAttackSkillTemplate::load(Str16 fileName, IMGExternalPackManager* packManager/* = NULL*/) { CsvReader csvreader; // MG_CN_MODIFY if(!csvreader.create(fileName, packManager)) { return false; } CsvData* csvdata = NULL; Int rowCount = csvreader.count(); for(Int i = 0; i < rowCount; ++i) { csvdata = csvreader.findValue(i); if(!csvdata) { continue; } LongRangeGeneralAttackSkillInfo* tempInfo = MG_NEW LongRangeGeneralAttackSkillInfo; MGStrOp::toU32(csvdata->mData[SKILLTYPEID].c_str(), tempInfo->skillTypeId); MGStrOp::toU32(csvdata->mData[SKILLTYPEGROUPID].c_str(), tempInfo->skillTypeGroupId); tempInfo->name = csvdata->mData[NAME]; tempInfo->text = csvdata->mData[TEXT]; tempInfo->kindName = csvdata->mData[KINDNAME]; MGStrOp::toU32(csvdata->mData[ARTICONID].c_str(), tempInfo->artIconId); for(UInt i = 0; i < 4; ++i) { tempInfo->skillExpression[i].action = csvdata->mData[ACTION1 + 3 * i]; MGStrOp::toU32(csvdata->mData[ACTION1 + 3 * i + 1].c_str(), tempInfo->skillExpression[i].artEffectId); MGStrOp::toU32(csvdata->mData[ACTION1 + 3 * i + 2].c_str(), tempInfo->skillExpression[i].audioResId); } UInt tempArtEffectFlyType; MGStrOp::toU32(csvdata->mData[ARTEFFECTFLYTYPE].c_str(), tempArtEffectFlyType); tempInfo->artEffectFlyType = (SkillFlyType)tempArtEffectFlyType; MGStrOp::toU32(csvdata->mData[ARTEFFECTFLYID].c_str(), tempInfo->artEffectFlyId); MGStrOp::toU32(csvdata->mData[ARTEFFECTFLYSPEED].c_str(), tempInfo->artEffectFlySpeed); tempInfo->artEffectFlySpeed /= 10; MGStrOp::toFlt(csvdata->mData[ATTACKFRONTTIME].c_str(), tempInfo->attackFrontTime); tempInfo->attackFrontTime /= 10; MGStrOp::toFlt(csvdata->mData[ATTACKBEHINDTIME].c_str(), tempInfo->attackBehindTime); tempInfo->attackBehindTime /= 10; MGStrOp::toU32(csvdata->mData[PUBLICTIMEPIECEID].c_str(), tempInfo->publicTimepieceId); MGStrOp::toU32(csvdata->mData[PUBLICTIMEPIECEDELAY].c_str(), tempInfo->publicTimepieceDelay); tempInfo->publicTimepieceDelay *= 100; MGStrOp::toU32(csvdata->mData[CHARACTERJUDGEID1].c_str(), tempInfo->characterJudgeId1); MGStrOp::toU32(csvdata->mData[CHARACTERJUDGEID2].c_str(), tempInfo->characterJudgeId2); MGStrOp::toFlt(csvdata->mData[RANGE].c_str(), tempInfo->range); tempInfo->range /= 10; MGStrOp::toFlt(csvdata->mData[MAXRANGE].c_str(), tempInfo->maxRange); tempInfo->maxRange /= 10; UInt tempAttackType; MGStrOp::toU32(csvdata->mData[ATTACKTYPE].c_str(), tempAttackType); tempInfo->attackType = (AttackType)tempAttackType; MGStrOp::toU32(csvdata->mData[FORMULAPARAMETERID].c_str(), tempInfo->formulaParameterId); MGStrOp::toU32(csvdata->mData[HATE].c_str(), tempInfo->hate); if (getLongRangeGeneralAttackSkillInfo(tempInfo->skillTypeId)) { DYNAMIC_ASSERT(false); MG_SAFE_DELETE(tempInfo); continue; } mLongRangeGeneralAttackSkillInfoList[tempInfo->skillTypeId] = tempInfo; } return true; }
bool Data_EnemyParam::LoadDataFromCsv(){ // リストの解放 enemyList.Release(); // Csvを読み込むクラス CsvReader reader; // ファイル名を保持する TCHAR fileName[MAX_PATH]; // グループの内容を一時的に保持する変数 Data_EnemyParam_Each tmpEnemy; // ファイルが存在しない場合が何度か続いたらループを抜ける int nEmptyFile = 0; // 何番目の敵インデックスまで埋まっているか int index = 0; int actionIndex = 0; for(int n=1; n<=MAX_ENEMYPARAMFILE; n++){ sprintf_s(fileName, MAX_PATH-1, CSVFILE_ENEMYPARAM, n); // csvファイルを読み込んでグループに格納する if(reader.Open(fileName)){ tmpEnemy = Data_EnemyParam_Each(); nEmptyFile = 0; // 空ファイル数のリセット index = 0; // ダミー行 reader.NextLine(); // レファレンス用IDを取得する if(reader.Read() == CSV_READ_NOERROR){ if(reader.GetIntValue(0, 0) == 0){ continue; } tmpEnemy.data.refID = (WORD)reader.GetIntValue(0, 0); } // ダミー行 reader.NextLine(); // 敵の名前と属性と経験値を取得する if(reader.Read() == CSV_READ_NOERROR){ // バッファに直接値を入れる reader.GetValue(0, tmpEnemy.data.name, BATTLEUNIT_NAME_BYTES-1); // 属性を読み取る tmpEnemy.data.attr = (BYTE)reader.GetIntValue(1, DOLL_ATTR_NONE); // 経験値を読み取る tmpEnemy.data.exp = (DWORD)reader.GetIntValue(2, 0); // レベルを読み取る tmpEnemy.data.level = (WORD)reader.GetIntValue(3, 1); } // ダミー行 reader.NextLine(); // 敵の各パラメータを取得する reader.Read(); for(int i=0; i<NUM_ENEMYPARAM_DATA; i++){ tmpEnemy.data.param[i] = reader.GetIntValue(i, 0); } reader.NextLine(); // ステートの配列を取得する for(int i=0; i<MAX_INITIALSTATE; i++){ reader.Read(); tmpEnemy.SetInitialState( i, reader.GetIntValue(0, 0), reader.GetIntValue(1, 0), reader.GetIntValue(2, 0)); } reader.NextLine(); // 敵の攻撃パターンを取得する for(int i=0; i<MAX_ACTIONPATTERN; i++){ // 各行動は三行に分けて記述する。 // 一行目:攻撃パターン名、スキルID、ターゲットのタイプ、優先度 // 二行目、三行目:条件、条件に関するパラメータ(3つ) reader.Read(); // 一行目 tmpEnemy.SetActionPattern(i, 0, (DWORD)reader.GetIntValue(0, 0)); tmpEnemy.SetActionPattern(i, 1, (BYTE)reader.GetIntValue(1, 0)); tmpEnemy.SetActionPattern(i, 2, (WORD)reader.GetIntValue(2, 0)); // 二行目、三行目 for(int j=0; j<MAX_CONDITION; j++){ reader.Read(); tmpEnemy.SetActConditionPattern( i, j, reader.GetIntValue(0, 0)); for(int k=0; k<MAX_CONDITIONPARAM; k++){ tmpEnemy.SetActConditionParam( i, j, k, reader.GetIntValue(1+k, 0)); } } // ダミー行 reader.NextLine(); } // 取得したグループをデータベースにセットする enemyList.AddData(tmpEnemy); }else{ nEmptyFile++; if(nEmptyFile > 100){ // 空ファイルが続いた場合、ループを抜ける break; } } } return true; }
//-------------------------------------------------------------------------- Bool InstanceAtkStrengthListCsv::load(const Char16* FileName, IMGExternalPackManager* packManager/* = NULL*/) { CsvReader csvreader; if(!csvreader.create(FileName, packManager)) { return false; } DYNAMIC_ASSERT(csvreader.getColumnSize() == InstanceAtkStrengthListCsvRow_Max); CsvData* csvdata = NULL; Int RowCount = csvreader.count(); for(Int i = 0; i < RowCount; ++i) { csvdata = csvreader.findValue(i); if(!csvdata) { continue; } CampIdType campId; MGStrOp::toU64(csvdata->mData[InstanceAtkStrengthListCsvRow_CampId].c_str(), campId); if (true == mInstanceAtkStrengthList.hasData(campId)) { DYNAMIC_ASSERT(0); continue; } U32 buildTemplateId; MGStrOp::toU32(csvdata->mData[InstanceAtkStrengthListCsvRow_CharacterBuildId].c_str(), buildTemplateId); U32 campPoint; MGStrOp::toU32(csvdata->mData[InstanceAtkStrengthListCsvRow_CampPointId].c_str(), campPoint); U32 generalRefreshPoint; MGStrOp::toU32(csvdata->mData[InstanceAtkStrengthListCsvRow_GeneraRefreshpoint].c_str(), generalRefreshPoint); U32 generalAlivePoint; MGStrOp::toU32(csvdata->mData[InstanceAtkStrengthListCsvRow_GeneraSpawnPoint].c_str(), generalAlivePoint); U32 armyPoint01; MGStrOp::toU32(csvdata->mData[InstanceAtkStrengthListCsvRow_ArmyPlayedPoint01].c_str(), armyPoint01); U32 armyPoint02; MGStrOp::toU32(csvdata->mData[InstanceAtkStrengthListCsvRow_ArmyPlayedPoint02].c_str(), armyPoint02); U32 armyPoint03; MGStrOp::toU32(csvdata->mData[InstanceAtkStrengthListCsvRow_ArmyPlayedPoint03].c_str(), armyPoint03); U32 armyPoint04; MGStrOp::toU32(csvdata->mData[InstanceAtkStrengthListCsvRow_ArmyPlayedPoint04].c_str(), armyPoint04); U32 armyPoint05; MGStrOp::toU32(csvdata->mData[InstanceAtkStrengthListCsvRow_ArmyPlayedPoint05].c_str(), armyPoint05); InstanceAtkStrengthListCsvInfo* newInfo = mInstanceAtkStrengthList.createOrRetrieve(campId, false); newInfo->campId = campId; newInfo->buildTemplateId = buildTemplateId; newInfo->campPoint = campPoint; newInfo->generalRefreshPoint = generalRefreshPoint; newInfo->generalAlivePoint = generalAlivePoint; newInfo->armyPoint[0] = armyPoint01; newInfo->armyPoint[1] = armyPoint02; newInfo->armyPoint[2] = armyPoint03; newInfo->armyPoint[3] = armyPoint04; newInfo->armyPoint[4] = armyPoint05; } return true; }
//------------------------------------------------------------------------------------------------------- MG::Bool CharacterGenrealList::loadFile( Str16 filename ) { CsvReader csvreader; if(!csvreader.create(filename)) { return false; } CsvData* csvdata = NULL; Int RowCount = csvreader.count(); for(int i = 0; i < RowCount; ++i) { csvdata = csvreader.findValue(i); if(!csvdata) { continue; } CharacterGenrealInfo* tempCharInfo = new CharacterGenrealInfo; UInt nCol = 0; MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->CharacterGeneralId); tempCharInfo->SurName = csvdata->mData[nCol++].c_str(); tempCharInfo->Name = csvdata->mData[nCol++].c_str(); tempCharInfo->ZhiName = csvdata->mData[nCol++].c_str(); tempCharInfo->Title = csvdata->mData[nCol++].c_str(); tempCharInfo->Tips = csvdata->mData[nCol++].c_str(); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), (U32&)tempCharInfo->GenderType ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), (U32&)tempCharInfo->PowerfulType ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), (U32&)tempCharInfo->RaceType ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), (U32&)tempCharInfo->FormulaType ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->Level ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->LineageLevel ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), (U32&)tempCharInfo->AbilityRandomType ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->AbilityAppendId1 ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->AbilityAppendId2 ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->AbilityAppendId3 ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->AbilityAppendId4 ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->AbilityAppendId5 ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->AbilityAppendId6 ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->CharacterSkillId1 ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->CharacterSkillId2 ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->Age ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->MinLifeSpan ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->MaxLifeSpan ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->NatureId ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->CharacterAppellationId ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->CharacterDialogId ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->OfficialLevelId ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->TitleId ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->ArtIconId1 ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->ArtIconId2 ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->ArtMashId1 ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->ArtMashId2 ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->ArtMashId3 ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->WeaponAcction ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->AudioResId ); mMapCharacterGenrealInfo[tempCharInfo->CharacterGeneralId] = tempCharInfo; } return true; }
//Save Document BOOL SaveCSV(const TCHAR*filepath){ csvReader.save(filepath); return TRUE; }
//------------------------------------------------------------------------------------------------- // MG_CN_MODIFY Bool FightAITemplate::load( Str16 fileName, IMGExternalPackManager* packManager/* = NULL*/ ) { CsvReader csvreader; // MG_CN_MODIFY if(!csvreader.create(fileName, packManager)) { return false; } CsvData* csvdata = NULL; Int RowCount = csvreader.count(); for(int i = 0; i < RowCount; ++i) { csvdata = csvreader.findValue(i); if(!csvdata) { continue; } FightAIInfo* tempInfo = new FightAIInfo; MGStrOp::toU32(csvdata->mData[AIFIGHTID].c_str(), tempInfo->aiFightId); MGStrOp::toU32(csvdata->mData[PRIORITY].c_str(), tempInfo->priority); UInt tempContactType = 0; MGStrOp::toU32(csvdata->mData[CONTACTTYPE].c_str(), tempContactType); tempInfo->contactType = (ContactType)tempContactType; UInt tempContactCharacterType = 0; MGStrOp::toU32(csvdata->mData[CONTACTPARAM1].c_str(), tempContactCharacterType); tempInfo->contactParam1 = (ContactCharacterType)tempContactCharacterType; MGStrOp::toFlt(csvdata->mData[CONTACTPARAM2].c_str(), tempInfo->contactParam2); MGStrOp::toFlt(csvdata->mData[CONTACTPARAM3].c_str(), tempInfo->contactParam3); MGStrOp::toFlt(csvdata->mData[CONTACTPARAM4].c_str(), tempInfo->contactParam4); switch(tempInfo->contactType) { case CT_ContactType1: case CT_ContactType7: case CT_ContactType8: tempInfo->contactParam2 /= 10; break; } MGStrOp::toU32(csvdata->mData[RANDOMNUM].c_str(), tempInfo->randomNum); MGStrOp::toU32(csvdata->mData[CONTACTNUM].c_str(), tempInfo->contactNum); UInt tempEventType = 0; MGStrOp::toU32(csvdata->mData[EVENTTYPE].c_str(), tempEventType); tempInfo->eventType = (EventType)tempEventType; UInt tempEventCharacterType = 0; MGStrOp::toU32(csvdata->mData[EVENTPARAM1].c_str(), tempEventCharacterType); tempInfo->eventParam1 = (EventCharacterType)tempEventCharacterType; MGStrOp::toU32(csvdata->mData[EVENTPARAM2].c_str(), tempInfo->eventParam2); MGStrOp::toU32(csvdata->mData[EVENTPARAM3].c_str(), tempInfo->eventParam3); MGStrOp::toU32(csvdata->mData[EVENTPARAM4].c_str(), tempInfo->eventParam4); mFightAIInfoList[tempInfo->aiFightId] = tempInfo; } return true; }
// // FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { static int cxClient, cyClient; static int cxChar, cyChar; static int iScollPos; int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; wstring s; RECT rc = { 0, 0, 0, 0 }; TCHAR szText[200]; switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_ABOUT: DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); break; case IDM_EXIT: DestroyWindow(hWnd); break; case IDM_FILE_OPEN: OpenDialog(hWnd); SetScrollPos(hWnd, SB_VERT, iScollPos, FALSE); InvalidateRect(hWnd, NULL, TRUE); break; case IDM_FILE_SAVE: OpenSaveDialog(hWnd); break; case IDM_RANDOMSORT_ITEM_1: csvReader.randSort(0); InvalidateRect(hWnd, NULL, TRUE); break; case IDM_RANDOMSORT_ITEM_2: csvReader.randSort(1); InvalidateRect(hWnd, NULL, TRUE); break; case IDM_RANDOMSORT_ITEM_3: csvReader.randSort(2); InvalidateRect(hWnd, NULL, TRUE); break; case IDM_RANDOMSORT_ITEM_4: csvReader.randSort(3); InvalidateRect(hWnd, NULL, TRUE); break; case IDM_RANDOMSORT_ITEM_5: csvReader.randSort(4); InvalidateRect(hWnd, NULL, TRUE); break; case IDM_RANDOMSORT_ITEM_6: csvReader.randSort(5); InvalidateRect(hWnd, NULL, TRUE); break; case IDM_RANDOMSORT_ITEM_7: csvReader.randSort(6); InvalidateRect(hWnd, NULL, TRUE); break; case IDM_RANDOMSORT_ITEM_8: csvReader.randSort(7); InvalidateRect(hWnd, NULL, TRUE); break; case IDM_RANDOMSORT_ITEM_9: csvReader.randSort(8); InvalidateRect(hWnd, NULL, TRUE); break; case IDM_RANDOMSORT_ITEM_10: csvReader.randSort(9); InvalidateRect(hWnd, NULL, TRUE); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_CREATE: hdc = GetDC(hWnd); //Get Text Height and Width TEXTMETRIC tm; GetTextMetrics(hdc, &tm); cxChar = tm.tmAveCharWidth; cyChar = tm.tmHeight + tm.tmExternalLeading; ReleaseDC(hWnd, hdc); // Create the Header control //hHeader = CreateWindowEx(0, WC_HEADER, 0, // HDS_BUTTONS | WS_CHILD | WS_VISIBLE, // 0, 0, 0, 0, // hWnd, (HMENU)IDC_HEADER, hInst, 0); //// Resize the header control //GetClientRect(hWnd, &rc); //OnHeaderSize(hWnd, 0, rc.right, rc.bottom); //// Set the font for the header common control //SendMessage(hHeader, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0); // Create the StatusBar hStatusbar = CreateWindowEx(0, STATUSCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP, 0, 0, 0, 0, hWnd, (HMENU)IDC_MAIN_STATUS, GetModuleHandle(NULL), NULL); // Store the statusbar control handle as the user data associated with // the parent window so that it can be retrieved for later use. SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)hStatusbar); InitStatusbar(hStatusbar); // Add 4 Header items for (UINT i = 0; i < 4; i++) { HDITEM hdi = { 0 }; hdi.mask = HDI_WIDTH | HDI_FORMAT | HDI_TEXT; hdi.cxy = rc.right / 4; hdi.fmt = HDF_CENTER; swprintf_s(szText, 200, L"Header %d", i); hdi.pszText = szText; hdi.cchTextMax = 200; SendMessage(hHeader, HDM_INSERTITEM, i, (LPARAM)&hdi); } case WM_PAINT: hdc = BeginPaint(hWnd, &ps); // TODO: Add any drawing code here... TCHAR buffer[20]; s += L"Text Height"; wsprintf(buffer, L"%d ", cyChar); s.append(buffer); s += L" Text Width"; wsprintf(buffer, L"%d ", cxChar); s += buffer; //TextOut(hdc, 0, 20, s.c_str(), s.length()); if (csvReader.isOpened()){ const int columnCount = csvReader.getHeadRow()->getColumnSize(); wstring *heads = new wstring[columnCount]; for (int i = 0; i < columnCount; i++){ heads[i].append(csvReader.getHeadRow()->getColumn(i)); } TextOut(hdc, 0, 0, (LPWSTR)csvReader.getHeader(), lstrlen(csvReader.getHeader())); int curStart = 0; EditRow *per; int count; curStart = iScollPos; int end = curStart + cyClient / cyChar; for (int i = curStart ; i < end; i++){ csvReader.getRow(i,&per); count = per->getColumnSize(); int j; for (j = 0; j < count-1; j++){ TextOut(hdc, j*COLUMN_WIDTH, (i-curStart + 1)*cyChar, per->getColumn(j),lstrlen(per->getColumn(j))); } wstring sTailRow(per->getColumn(j)); int fpos = -1; if (fpos = sTailRow.find(_T("\n"))){ sTailRow.erase(fpos, 2); } TextOut(hdc, j*COLUMN_WIDTH, (i - curStart + 1)*cyChar, sTailRow.c_str(), sTailRow.length()); } } EndPaint(hWnd, &ps); break; case WM_VSCROLL: switch (LOWORD(wParam)){ case SB_LINEUP: iScollPos -= 1; break; case SB_LINEDOWN: iScollPos += 1; break; case SB_PAGEUP: iScollPos -= cyClient / cyChar; break; case SB_PAGEDOWN: iScollPos += cyClient / cyChar; break; case SB_THUMBPOSITION: iScollPos = HIWORD(wParam); break; default: break; } iScollPos =max(0, min(iScollPos, csvReader.getRowCount())); if (iScollPos != GetScrollPos(hWnd, SB_VERT)) { SetScrollPos(hWnd, SB_VERT, iScollPos, TRUE); InvalidateRect(hWnd, NULL, TRUE); } break; case WM_SIZE: cxClient = LOWORD(lParam); cyClient = HIWORD(lParam); //InvalidateRect(hStatusbar, NULL, TRUE); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
//------------------------------------------------------------------------------------------- // MG_CN_MODIFY Bool ParabolaAreaSkillTemplate::load(Str16 fileName, IMGExternalPackManager* packManager/* = NULL*/) { CsvReader csvreader; // MG_CN_MODIFY if(!csvreader.create(fileName, packManager)) { return false; } CsvData* csvdata = NULL; Int rowCount = csvreader.count(); for(Int i = 0; i < rowCount; ++i) { csvdata = csvreader.findValue(i); if(!csvdata) { continue; } ParabolaAreaSkillInfo* tempInfo = MG_NEW ParabolaAreaSkillInfo; MGStrOp::toU32(csvdata->mData[SKILLTYPEID].c_str(), tempInfo->skillTypeId); MGStrOp::toU32(csvdata->mData[SKILLTYPEGROUPID].c_str(), tempInfo->skillTypeGroupId); MGStrOp::toU32(csvdata->mData[SKILLLEVEL].c_str(), tempInfo->skillLevel); tempInfo->name = csvdata->mData[NAME]; tempInfo->text = csvdata->mData[TEXT]; tempInfo->kindName = csvdata->mData[KINDNAME]; MGStrOp::toU32(csvdata->mData[ARTICONID].c_str(), tempInfo->artIconId); //MGStrOp::toU32(csvdata->mData[ACTIONTIME].c_str(), tempInfo->actionTime); for(UInt i = 0; i < 2; ++i) { tempInfo->skillExpression[i+1].action = csvdata->mData[ACTION2 + 3 * i]; MGStrOp::toU32(csvdata->mData[ACTION2 + 3 * i + 1].c_str(), tempInfo->skillExpression[i+1].artEffectId); MGStrOp::toU32(csvdata->mData[ACTION2 + 3 * i + 2].c_str(), tempInfo->skillExpression[i+1].audioResId); } MGStrOp::toU32(csvdata->mData[POINTEFFECTID].c_str(), tempInfo->pointEffectId); MGStrOp::toU32(csvdata->mData[ARTEFFECTFLYID].c_str(), tempInfo->artEffectFlyId); Flt tempSpeed = 0; MGStrOp::toFlt(csvdata->mData[ARTEFFECTFLYSPEED].c_str(), tempSpeed); tempInfo->artEffectFlySpeed = tempSpeed / 10; MGStrOp::toU32(csvdata->mData[POINTAUDIOID].c_str(), tempInfo->pointAudioId); UInt tempParabolaType = 0; MGStrOp::toU32(csvdata->mData[PARABOLATYPE].c_str(), tempParabolaType); tempInfo->parabolaType = (ParabolaType)tempParabolaType; UInt tempParabolaAngle = 0; MGStrOp::toU32(csvdata->mData[PARABOLAANGLE].c_str(), tempParabolaAngle); tempInfo->parabolaAngle = tempParabolaAngle; MGStrOp::toFlt(csvdata->mData[ATTACKFRONTTIME].c_str(), tempInfo->attackFrontTime); tempInfo->attackFrontTime /= 10; MGStrOp::toFlt(csvdata->mData[ATTACKBEHINDTIME].c_str(), tempInfo->attackBehindTime); tempInfo->attackBehindTime /= 10; MGStrOp::toU32(csvdata->mData[PUBLICTIMEPIECEID].c_str(), tempInfo->publicTimepieceId); MGStrOp::toU32(csvdata->mData[PUBLICTIMEPIECEDELAY].c_str(), tempInfo->publicTimepieceDelay); tempInfo->publicTimepieceDelay *= 100; MGStrOp::toU32(csvdata->mData[OWNERTIMEPIECEID].c_str(), tempInfo->ownerTimepieceId); MGStrOp::toU32(csvdata->mData[OWNERTIMEPIECEDELAY].c_str(), tempInfo->ownerTimepieceDelay); tempInfo->ownerTimepieceDelay *= 100; MGStrOp::toU32(csvdata->mData[RESETTIMEPIECEID].c_str(), tempInfo->resetTimepieceId); MGStrOp::toU32(csvdata->mData[RESETTIMEPIECEGROUPID].c_str(), tempInfo->resetTimepieceGroupId); MGStrOp::toU32(csvdata->mData[CHARACTERJUDGEID1].c_str(), tempInfo->characterJudgeId1); MGStrOp::toU32(csvdata->mData[CHARACTERJUDGEID2].c_str(), tempInfo->characterJudgeId2); MGStrOp::toFlt(csvdata->mData[RANGE].c_str(), tempInfo->range); tempInfo->range /= 10; MGStrOp::toFlt(csvdata->mData[MAXRANGE].c_str(), tempInfo->maxRange); tempInfo->maxRange /= 10; MGStrOp::toFlt(csvdata->mData[SKILLRADIUO].c_str(), tempInfo->skillRadius); tempInfo->skillRadius /= 10; MGStrOp::toU32(csvdata->mData[ATTACKNUM].c_str(), tempInfo->attackNum); UInt tempShareType; MGStrOp::toU32(csvdata->mData[SHARETYPE].c_str(), tempShareType); tempInfo->shareType = (ShareType)tempShareType; UInt tempSpendType; MGStrOp::toU32(csvdata->mData[SPENDTYPE].c_str(), tempSpendType); tempInfo->spendType = (SpendType)tempSpendType; MGStrOp::toU32(csvdata->mData[FORMULAPARAMETERID2].c_str(), tempInfo->formulaParameterId2); UInt tempAttackType; MGStrOp::toU32(csvdata->mData[ATTACKTYPE].c_str(), tempAttackType); tempInfo->attackType = (AttackType)tempAttackType; MGStrOp::toU32(csvdata->mData[FORMULAPARAMETERID1].c_str(), tempInfo->formulaParameterId); UInt tempDamageType; MGStrOp::toU32(csvdata->mData[DAMAGETYPE].c_str(), tempDamageType); tempInfo->damageType = (DamageType)tempDamageType; MGStrOp::toU32(csvdata->mData[RANDOMSTATE].c_str(), tempInfo->randomState); MGStrOp::toU32(csvdata->mData[STATEID].c_str(), tempInfo->stateId); MGStrOp::toU32(csvdata->mData[STATENUM].c_str(), tempInfo->stateNum); MGStrOp::toU32(csvdata->mData[HATE].c_str(), tempInfo->hate); if (getParabolaAreaSkillInfo(tempInfo->skillTypeId)) { DYNAMIC_ASSERT(false); MG_SAFE_DELETE(tempInfo); continue; } mParabolaAreaSkillInfoList[tempInfo->skillTypeId] = tempInfo; } return true; }
//-------------------------------------------------------------------------- // MG_CN_MODIFY Bool MapListCsv::load(const Char16* FileName, IMGExternalPackManager* packManager/* = NULL*/) { CsvReader csvreader; // MG_CN_MODIFY if(!csvreader.create(FileName, packManager)) { return false; } CsvData* csvdata = NULL; Int RowCount = csvreader.count(); for(Int i = 0; i < RowCount; ++i) { csvdata = csvreader.findValue(i); if(!csvdata) { continue; } MapIdType mapListId = -1; MGStrOp::toU32(csvdata->mData[MLC_MapId].c_str(), mapListId); if (true == mMapList.hasData(mapListId)) { DYNAMIC_ASSERT(0); continue; } Str mapGroupName = ""; MGStrOp::toString(csvdata->mData[MLC_MapGroupName].c_str(), mapGroupName); Int mapOpenType = -1; MGStrOp::toI32(csvdata->mData[MLC_OpenType].c_str(), mapOpenType); Int mapType = -1; MGStrOp::toI32(csvdata->mData[MLC_MapType].c_str(), mapType); ArtMapResIdType artMapResId = -1; MGStrOp::toI32(csvdata->mData[MLC_ArtMapResId].c_str(), artMapResId); U32 audioResID = -1; MGStrOp::toU32(csvdata->mData[MLC_AudioResId].c_str(), audioResID); ArtPointResId rpgJumpPointId = 0; MGStrOp::toI32(csvdata->mData[MLC_RpgJumpPointId].c_str(), rpgJumpPointId); ArtPointResId rpgAlivePointId = 0; MGStrOp::toI32(csvdata->mData[MLC_RpgAlivePointId].c_str(), rpgAlivePointId); ArtPointResId slgAttackJumpPointId = 0; MGStrOp::toI32(csvdata->mData[MLC_SlgAttackJumpPointId].c_str(), slgAttackJumpPointId); ArtPointResId slgAttackAlivePointId = 0; MGStrOp::toI32(csvdata->mData[MLC_SlgAttackAlivePointId].c_str(), slgAttackAlivePointId); ArtPointResId slgDefenseJumpPointId = 0; MGStrOp::toI32(csvdata->mData[MLC_SlgDefenseJumpPointId].c_str(), slgDefenseJumpPointId); ArtPointResId slgDefenseAlivePointId = 0; MGStrOp::toI32(csvdata->mData[MLC_SlgDefenseAlivePointId].c_str(), slgDefenseAlivePointId); MapListCsvInfo* newMapInfo = mMapList.createOrRetrieve(mapListId, false); newMapInfo->mapListId = mapListId; newMapInfo->mapGroupName = csvdata->mData[MLC_MapGroupName]; newMapInfo->mapName = csvdata->mData[MLC_MapName]; newMapInfo->mapText = csvdata->mData[MLC_MapText]; newMapInfo->mapOpenType = (MapOpenType)mapOpenType; newMapInfo->mapType = (MapType)mapType; newMapInfo->artMapResId = artMapResId; newMapInfo->fileName = csvdata->mData[MLC_MapFileName]; newMapInfo->filePath = csvdata->mData[MLC_MapFilePath]; newMapInfo->audioResID = audioResID; newMapInfo->rpgJumpPointId = rpgJumpPointId; newMapInfo->rpgAlivePointId = rpgAlivePointId; newMapInfo->slgAttackJumpPointId = slgAttackJumpPointId; newMapInfo->slgAttackAlivePointId = slgAttackAlivePointId; newMapInfo->slgDefenseJumpPointId = slgDefenseJumpPointId; newMapInfo->slgDefenseAlivePointId = slgDefenseAlivePointId; } return true; }
//------------------------------------------------------------------------------------------------------- // MG_CN_MODIFY MG::Bool CharacterGenrealList::loadFile( Str16 filename, IMGExternalPackManager* packManager/* = NULL*/ ) { CsvReader csvreader; // MG_CN_MODIFY if(!csvreader.create(filename, packManager)) { return false; } CsvData* csvdata = NULL; Int RowCount = csvreader.count(); for(int i = 0; i < RowCount; ++i) { csvdata = csvreader.findValue(i); if(!csvdata) { continue; } CharacterGenrealInfo* tempCharInfo = new CharacterGenrealInfo; UInt nCol = 0; MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->CharacterGeneralId); nCol++; tempCharInfo->ListName = csvdata->mData[nCol++].c_str(); tempCharInfo->SurName = csvdata->mData[nCol++].c_str(); tempCharInfo->Name = csvdata->mData[nCol++].c_str(); tempCharInfo->Title = csvdata->mData[nCol++].c_str(); tempCharInfo->Tips = csvdata->mData[nCol++].c_str(); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), (U32&)tempCharInfo->GenderType ); DYNAMIC_ASSERT(tempCharInfo->GenderType> GENDER_TYPE_NULL && tempCharInfo->GenderType < GENDER_TYPE_MAX); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), (U32&)tempCharInfo->PowerfulType ); DYNAMIC_ASSERT(tempCharInfo->PowerfulType> POWERFUL_TYPE_NULL && tempCharInfo->PowerfulType < POWERFUL_TYPE_MAX); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), (U32&)tempCharInfo->FormulaType ); DYNAMIC_ASSERT(tempCharInfo->FormulaType> CHAR_FORMULA_TYPE_NULL && tempCharInfo->FormulaType < CHAR_FORMULA_TYPE_MAX); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->Level ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->LineageLevel ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->AbilityInitId1 ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->AbilityInitId2 ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->AbilityInitId3 ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->AbilityAppendId ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->CharacterSkillId1 ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->CharacterSkillId2 ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->Age ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->MinLifeSpan ); //MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->MaxLifeSpan ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->NatureId ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->CharacterAppellationId ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->CharacterDialogId ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->ArtIconId ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->ArtMashId1 ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->ArtMashId2 ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->ArtMashId3 ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->WeaponAcction ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->CharacterVisionEventListId ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->AIBaseGroupId ); MGStrOp::toU32(csvdata->mData[nCol++].c_str(), tempCharInfo->AIFightGroupId ); mMapCharacterGenrealInfo[tempCharInfo->CharacterGeneralId] = tempCharInfo; } return true; }
inputData_t generateInputData() { CsvReader reader; MatrixXd matrix = reader.csvReadToMatrix(TRAIN_DATA_FILE); if (matrix.rows() == 0 && matrix.cols() == 0) { printf("Error leyendo data.\n"); exit(-1); } else { cout << "cantidad de features: " << (matrix.cols() - 1) << endl << endl; } //shuflear toda la matrix PermutationMatrix<Dynamic, Dynamic> permutacionFilasRandom(matrix.rows()); permutacionFilasRandom.setIdentity(); srand(time(0)); random_shuffle(permutacionFilasRandom.indices().data(), permutacionFilasRandom.indices().data() + permutacionFilasRandom.indices().size()); matrix = permutacionFilasRandom * (matrix); // Recuce el tamanio de la matriz para poder testear. // TODO Para correr con todos los datos cambiar DATA_SIZE = 1. int nuevo_ultimo_indice = round(matrix.rows() * DATA_SIZE); matrix.conservativeResize(nuevo_ultimo_indice, matrix.cols()); int ultimo_indice_train = round(matrix.rows() * 0.8); int ultimo_indice_test = round(matrix.rows() * 0.9); MatrixXd matrix_train = matrix.block(0, 0, ultimo_indice_train, matrix.cols()); MatrixXd matrix_test = matrix.block(ultimo_indice_train, 0, ultimo_indice_test - ultimo_indice_train, matrix_train.cols()); MatrixXd matrix_validation = matrix.block(ultimo_indice_test, 0, matrix.rows() - ultimo_indice_test, matrix_train.cols()); matrix.resize(0, 0); inputData_t data; //separar matrix_train en x_train, y_train //separar matrix_test en x_test, y_test data.x_train = matrix_train.block(0, 0, matrix_train.rows(), matrix_train.cols() - 1); data.y_train = (matrix_train.block(0, matrix_train.cols() - 1, matrix_train.rows(), 1)); //me dice que puse different types data.x_test = matrix_test.block(0, 0, matrix_test.rows(), matrix_test.cols() - 1); data.y_test = matrix_test.block(0, matrix_test.cols() - 1, matrix_test.rows(), 1); data.x_validation = matrix_validation.block(0, 0, matrix_validation.rows(), matrix_validation.cols() - 1); data.y_validation = matrix_validation.block(0, matrix_validation.cols() - 1, matrix_validation.rows(), 1); matrix_train.resize(0, 0); matrix_test.resize(0, 0); cout << "Train x: " << data.x_train.rows() << "x" << data.x_train.cols() << "\n"; cout << "Train y: " << data.y_train.rows() << "x" << data.y_train.cols() << "\n"; cout << "Test x: " << data.x_test.rows() << "x" << data.x_test.cols() << "\n"; cout << "Test y: " << data.y_test.rows() << "x" << data.y_test.cols() << "\n"; cout << "Validation x: " << data.x_validation.rows() << "x" << data.x_validation.cols() << "\n"; cout << "Validation y: " << data.y_validation.rows() << "x" << data.y_validation.cols() << "\n"; return data; }
bool Data_DollParam_Each::Load(LPTSTR fileName){ CsvReader reader; // ファイルを開く if(!reader.Open(fileName)){ return false; } // 名前を読み込む reader.Read(); reader.GetValue(0, typeName, DOLL_TYPENAME_BYTES); // 空行を読む reader.Read(); // パラメータの上昇率を読み込む for(int n=0; n<DOLL_PARAM_MAX; n++){ // 一行読む reader.Read(); // 係数3つを取得する // 見やすさのために0番目の要素は能力値名を使用。 LvToP[n].a = reader.GetFloatValue(1); LvToP[n].b = reader.GetFloatValue(2); LvToP[n].c = reader.GetFloatValue(3); } // 空行を読む reader.Read(); // レベルアップボーナスを読み込む for(int n=0; n<DOLL_LEVEL_MAX; n++){ // 一行読む reader.Read(); // 各パラメータを取得する for(int m=0; m<DOLL_PARAM_MAX; m++){ LvBonus[n].growth[m] = reader.GetIntValue(m+1, 0); } LvBonus[n].skillID = reader.GetIntValue(DOLL_PARAM_MAX+1, 0); } return true; }
#define CATCH_CONFIG_MAIN #include "catch.hpp" //TEST_CASE("Test Case 1") //{ // REQUIRE(1 == 1); //} //TEST_CASE("Test Case 2") //{ // REQUIRE(1 == 2); //} TEST_CASE(" 1. Open CSV File 'input.csv'.") { CsvReader csvReader; SECTION("Analyze Trades read from input file") { std::string input_file_name("..\\input.csv"); auto status = csvReader.Open(input_file_name); REQUIRE(status == true); int rows = csvReader.Read(); //std::cout << "CSV file read - total rows = " << rows << std::endl; REQUIRE(rows == 20438); //REQUIRE(rows == 20440); csvReader.Close(); } }