diff --git a/Datas.cpp b/Datas.cpp index 3041268..8a5e10b 100644 --- a/Datas.cpp +++ b/Datas.cpp @@ -1179,7 +1179,7 @@ BOOL LoadAppDatas(CWnd *wnd) GOODS_COUNT = 0; EQUIP_COUNT = 0; - //InitializeHashTable(); + InitializeHashTable(); DetectMod(); g_resourceProvider.Init(g_flAppPath); diff --git a/DynEconDlg.cpp b/DynEconDlg.cpp index 10f704e..94d6a86 100644 --- a/DynEconDlg.cpp +++ b/DynEconDlg.cpp @@ -135,7 +135,7 @@ struct FlFactionInfo #define FLCREDITS_ADDR 0x00673364 #define FLPLAYERSHIP_ADDR 0x0067337C #define FLFACTIONS_ADDR 0x064018EC -#define FLPLAYERS_ADDR 0x064018C4 //0x064018C4 // FlTree des joueurs +#define FLPLAYERS_ADDR 0x064018C4 // FlTree des joueurs // 0x64018D8 = currentNode #define READFLMEM(structure,addr) if (!ReadProcessMemory(m_hflProcess, LPCVOID(addr), &structure, sizeof(structure), NULL)) return 0; #define READFLPTR(ptr,addr,size) if (!ReadProcessMemory(m_hflProcess, LPCVOID(addr), LPVOID(ptr), size, NULL)) return 0; @@ -277,6 +277,24 @@ HANDLE OpenGameProcess() return NULL; } +UINT CGameInspect::FoundPlayer(DWORD id, LPVOID ptr) +{ + FlPlayer player; + READFLMEM(player, ptr); + Log(L"Found player (ID %d): %s", id, player._playerName); + +/* + LPVOID playerPtr = TreeFind(playersTree, player_id); + if (playerPtr) + { + FlPlayer player; + READFLMEM(player, playerPtr); +*/ + + Log(L"Done with a found player"); + return 0; +} + int CGameInspect::DoTask(DWORD flags) { if (g_triggeredImport) @@ -371,63 +389,61 @@ int CGameInspect::DoTask(DWORD flags) } } } -#if 0 - if (true) //(flags & IMPORT_FACTIONS) + if (flags & IMPORT_FACTIONS) { - UINT changed = 0; + UINT removedAvoids = 0; + UINT addedAvoids = 0; CMap idFactionMap; UINT i; for (i = 0; i < FACTIONS_COUNT; i++) idFactionMap[FLFactionHash(g_factions[i].m_nickname)] = &g_factions[i]; - FlTree factionsTree; - READFLMEM(factionsTree, FLFACTIONS_ADDR); + DWORD player_id; + READFLMEM(player_id, FLCLIENTID_ADDR); - LPBYTE ptr; - READFLMEM(ptr, 0x61e0260); - DWORD player_id; - int oset = 0; - player_id = 0; - while (player_id==0) - { - READFLMEM(player_id, ptr + (4+ oset)); - oset += 4; - } + FlTree playersTree; + READFLMEM(playersTree, FLPLAYERS_ADDR); - FlTree playersTree; - READFLMEM(playersTree, FLPLAYERS_ADDR); - FlNode playerNode; - READFLMEM(playerNode, playersTree._Head); - READFLMEM(playerNode, playerNode._Parent); - LPVOID playerPtr = TreeFind(playersTree, 1); - if (playerPtr) - { - FlPlayer player; - READFLMEM(player, playerPtr); - int count = player._repsEnd-player._repsBegin; - //CScopedArray reps = new FlRep[count]; - //READFLPTR(reps,player._repsBegin, count*sizeof(FlRep)); - for (int index = 0; index < count; index++) - //if (reps[index]._rep <= -0.6) - { - //CFaction *faction = idFactionMap[reps[index]._faction_id]; - ////if (!faction->m_avoid) - { - changed++; - //faction->m_avoid = true; - } - } + TreeForEach(playersTree, &CGameInspect::FoundPlayer); + + LPVOID playerPtr = TreeFind(playersTree, player_id); + if (playerPtr) + { + FlPlayer player; + READFLMEM(player, playerPtr); + int bytes = (reinterpret_cast(player._repsEnd) - reinterpret_cast(player._repsBegin)); + int count = bytes / sizeof(FlRep); + FlRep* reps = (FlRep*)malloc(bytes); + READFLPTR(reps, player._repsBegin, bytes); + + for (i = 0; i < FACTIONS_COUNT; i++) { + if (g_factions[i].m_avoid) { + g_factions[i].m_avoid = false; + removedAvoids++; } - if (changed) + } + + for (int index = 0; index < count; index++) { + if (reps[index]._rep <= -0.55) { - Log(L"Imported from game: %d factions to avoid", changed); - g_mainDlg->Recalc(g_mainDlg->RECALC_PATHS); + CFaction *faction = idFactionMap[reps[index]._faction_id]; + if (faction != nullptr) + { + addedAvoids++; + faction->m_avoid = true; + } } - + } + free(reps); + } + if (removedAvoids > 0 || addedAvoids > 0) + { + Log(L"Imported from game: %d factions no longer avoided, %d new factions to avoid", removedAvoids, addedAvoids); + g_mainDlg->Recalc(g_mainDlg->RECALC_PATHS); + } } -#endif SetPriorityClass(m_hflProcess, dwPriorityClass); } return 1; diff --git a/DynEconDlg.h b/DynEconDlg.h index 747d420..344b53e 100644 --- a/DynEconDlg.h +++ b/DynEconDlg.h @@ -24,11 +24,12 @@ class CGameInspect IMPORT_PRICES = 0x01, IMPORT_CREDITS = 0x02, IMPORT_CARGOHOLD = 0x04, - //IMPORT_FACTIONS = 0x08, + IMPORT_FACTIONS = 0x08, }; int DoTask(DWORD flags); private: UINT CollectGoodPrice(DWORD id, LPVOID ptr); + UINT FoundPlayer(DWORD id, LPVOID ptr); UINT CollectFactions(DWORD id, LPVOID ptr); UINT CGameInspect::TreeForEachRecurse(FlNode* nodePtr, FlNode* nodeNil, UINT (CGameInspect::*callback)(DWORD id, LPVOID ptr)); UINT TreeForEach(FlTree& tree, UINT (CGameInspect::*callback)(DWORD id, LPVOID ptr)); diff --git a/FLCompanion.aps b/FLCompanion.aps index 5f7daec..ce79b1e 100644 Binary files a/FLCompanion.aps and b/FLCompanion.aps differ diff --git a/FLCompanion.rc b/FLCompanion.rc index 8ef322b..4b2a42f 100644 --- a/FLCompanion.rc +++ b/FLCompanion.rc @@ -214,10 +214,10 @@ END ///////////////////////////////////////////////////////////////////////////// // -// IDConfig +// 256 // -IDR_MYTEXTFILE TEXTFILE "res\\IDHacks.ini" +IDR_MYTEXTFILE 256 "res\\IDHacks.ini" #endif // English (United States) resources ///////////////////////////////////////////////////////////////////////////// @@ -294,8 +294,7 @@ BEGIN PUSHBUTTON "Clear all",IDC_CLEAR_ALL_SYSTEMS,60,157,50,15 GROUPBOX "Exclude base by factions:",IDC_STATIC,125,15,110,160 RTEXT "Select Faction ID : ",IDC_STATIC,63,3,60,12 - COMBOBOX IDC_FACTION_ID, 125, 0, 150, 12, CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP - //LTEXT "[disabled]",IDC_STATIC,125,3,50,12 + COMBOBOX IDC_FACTION_ID,125,0,150,12,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP LISTBOX IDC_FACTIONS_LIST,130,25,100,131,LBS_SORT | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "Check all",IDC_CHECK_ALL_FACTIONS,130,157,50,15 PUSHBUTTON "Clear all",IDC_CLEAR_ALL_FACTIONS,180,157,50,15 @@ -399,6 +398,10 @@ BEGIN BOTTOMMARGIN, 69 END + IDD_LIMITATIONS_DIALOG, DIALOG + BEGIN + END + IDD_MININGBASE_DIALOG, DIALOG BEGIN LEFTMARGIN, 7 @@ -503,6 +506,7 @@ BEGIN MENUITEM "Bases prices (dynamic economy)", ID_GAME_IMPORT_PRICES, CHECKED MENUITEM "Your credits (max investment)", ID_GAME_IMPORT_CREDITS, CHECKED MENUITEM "Your ship's cargo hold size", ID_GAME_IMPORT_CARGOHOLD, CHECKED + MENUITEM "Your reputation (exclude hostile factions)", ID_GAME_IMPORT_FACTIONS, CHECKED MENUITEM SEPARATOR MENUITEM "Check/Uncheck all", ID_GAME_IMPORT_CHECKALL MENUITEM "About this feature...", ID_GAME_IMPORT_ABOUT diff --git a/FLCompanion.vcxproj b/FLCompanion.vcxproj index d950cec..ccdc2a1 100644 --- a/FLCompanion.vcxproj +++ b/FLCompanion.vcxproj @@ -15,7 +15,7 @@ MFCProj {919DA618-8031-401C-BAA1-0C4EC4219FCE} - 10.0.14393.0 + 10.0.17763.0 diff --git a/FLCompanionDlg.cpp b/FLCompanionDlg.cpp index 8dd89e1..6827126 100644 --- a/FLCompanionDlg.cpp +++ b/FLCompanionDlg.cpp @@ -155,9 +155,9 @@ BEGIN_MESSAGE_MAP(CFLCompanionDlg, CDialog) ON_UPDATE_COMMAND_UI(ID_MOD_INFO, OnUpdateModInfo) ON_BN_CLICKED(IDC_JUMPS, OnJumps) ON_BN_CLICKED(IDC_OPENMAP, OnMap) - ON_UPDATE_COMMAND_UI_RANGE(ID_GAME_IMPORT_PRICES, ID_GAME_IMPORT_CARGOHOLD, OnUpdateGameImport) + ON_UPDATE_COMMAND_UI_RANGE(ID_GAME_IMPORT_PRICES, ID_GAME_IMPORT_FACTIONS, OnUpdateGameImport) ON_COMMAND(ID_GAME_IMPORT_ABOUT, OnGameImportAbout) - ON_COMMAND_RANGE(ID_GAME_IMPORT_PRICES, ID_GAME_IMPORT_CARGOHOLD, OnGameImport) + ON_COMMAND_RANGE(ID_GAME_IMPORT_PRICES, ID_GAME_IMPORT_FACTIONS, OnGameImport) ON_COMMAND(ID_GAME_IMPORT_CHECKALL, OnGameImportCheckall) ON_UPDATE_COMMAND_UI(ID_GAME_IMPORT_CHECKALL, OnUpdateGameImportCheckall) ON_WM_ACTIVATEAPP() @@ -627,10 +627,10 @@ void CFLCompanionDlg::AddSolution(int goodIndex, double destbuy, double srcsell, { LONG profit; UINT units = m_cargoSize == 1 ? 1 : UINT(m_cargoSize/g_goods[goodIndex].m_volume); - if (units == 0) - return; if ((m_maxInvestment > 0) && (srcsell*units > m_maxInvestment)) units = UINT(m_maxInvestment/srcsell); + if (units == 0) + return; if (g_goods[goodIndex].m_decay_time == 0) profit = UINT(destbuy-srcsell)*units; else @@ -2010,7 +2010,7 @@ void CFLCompanionDlg::OnGameImportCheckall() if (m_importFromGame) m_importFromGame = 0; else - m_importFromGame = (1<<(ID_GAME_IMPORT_CARGOHOLD-ID_GAME_IMPORT_PRICES+1))-1; + m_importFromGame = (1<<(ID_GAME_IMPORT_FACTIONS-ID_GAME_IMPORT_PRICES+1))-1; theApp.WriteProfileInt(L"Settings", L"ImportFromGame", m_importFromGame); g_triggeredImport = true; ImportFromGame(); diff --git a/resource.h b/resource.h index a457ad4..998e686 100644 --- a/resource.h +++ b/resource.h @@ -2,6 +2,7 @@ // Microsoft Visual C++ generated include file. // Used by FLCompanion.rc // +#define IDR_MYTEXTFILE 101 #define IDD_FLCOMPANION_DIALOG 102 #define IDD_SPEEDDELAYS_DIALOG 103 #define IDD_SYSTEMMAP_DIALOG 104 @@ -20,7 +21,6 @@ #define IDI_JUMP 138 #define IDI_SWITCH_ARROW 139 #define TEXTFILE 256 -#define IDR_MYTEXTFILE 101 #define IDC_BASE_COMBO 1000 #define IDC_ROUTES 1001 #define IDC_SYSTEM_COMBO 1002 @@ -134,6 +134,7 @@ #define ID_GAME_IMPORT_PRICES 32800 #define ID_GAME_IMPORT_CREDITS 32801 #define ID_GAME_IMPORT_CARGOHOLD 32802 +#define ID_GAME_IMPORT_FACTIONS 32803 #define ID_VIEW_LOG 32811 #define ID_CLIENTREFRESH 32812 #define IDC_AVOIDGATES 32813 @@ -148,7 +149,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_3D_CONTROLS 1 #define _APS_NEXT_RESOURCE_VALUE 141 -#define _APS_NEXT_COMMAND_VALUE 32812 +#define _APS_NEXT_COMMAND_VALUE 32814 #define _APS_NEXT_CONTROL_VALUE 1068 #define _APS_NEXT_SYMED_VALUE 114 #endif