Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Datas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,7 @@ BOOL LoadAppDatas(CWnd *wnd)
GOODS_COUNT = 0;
EQUIP_COUNT = 0;

//InitializeHashTable();
InitializeHashTable();
DetectMod();

g_resourceProvider.Init(g_flAppPath);
Expand Down
104 changes: 60 additions & 44 deletions DynEconDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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<DWORD, DWORD, CFaction*, CFaction*> 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<FlRep> 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<int>(player._repsEnd) - reinterpret_cast<int>(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;
Expand Down
3 changes: 2 additions & 1 deletion DynEconDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Binary file modified FLCompanion.aps
Binary file not shown.
12 changes: 8 additions & 4 deletions FLCompanion.rc
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,10 @@ END

/////////////////////////////////////////////////////////////////////////////
//
// IDConfig
// 256
//

IDR_MYTEXTFILE TEXTFILE "res\\IDHacks.ini"
IDR_MYTEXTFILE 256 "res\\IDHacks.ini"

#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -399,6 +398,10 @@ BEGIN
BOTTOMMARGIN, 69
END

IDD_LIMITATIONS_DIALOG, DIALOG
BEGIN
END

IDD_MININGBASE_DIALOG, DIALOG
BEGIN
LEFTMARGIN, 7
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion FLCompanion.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<SccLocalPath />
<Keyword>MFCProj</Keyword>
<ProjectGuid>{919DA618-8031-401C-BAA1-0C4EC4219FCE}</ProjectGuid>
<WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug UNICODE|Win32'" Label="Configuration">
Expand Down
10 changes: 5 additions & 5 deletions FLCompanionDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down
5 changes: 3 additions & 2 deletions resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down