Skip to content

Commit

Permalink
Mod menu improvements
Browse files Browse the repository at this point in the history
MainMenu.sqs
- displays more detailed information when selected a mod from the list
- mod download size info depends on user's mod version (instead of showing size of the entire mod)
- added right-click options for mods
- added option to search through mods download list
- multiple mods can be downloaded at once
- option to start without mods only appears if there are mods loaded
- mod id file is updated when checking for updates
- images are downloaded to separate folders
- images are downloaded while viewing records instead of while checking for updates
- fixed issue where auto-update check was being run every time instead of once per game launch
- fixed issue where pressing enter in text input would go to the "mods" menu
- disabled user input trim because it would remove cyrillic characters

fwatch.dll
- on 1.99 Fwatch redirects the game to read island cutscenes from addons\ instead of res\addons\
- :file modlist - change output structure; returns entire mod config info

fwatch.exe
- on 1.99 Fwatch will rename res\bin\resource.cpp to res\bin\resource_disabled.cpp
- on 1.99 Fwatch will transfer island cutscenes from IslandCutscenes\_RES to addons\ (instead of res\addons\)
- doesn't create "res\addons" folder anymore

gameRestart.exe
- fixed issue where forcing mod name wouldn't work
  • Loading branch information
Faguss committed Sep 24, 2021
1 parent 710dc36 commit ded1d40
Show file tree
Hide file tree
Showing 9 changed files with 514 additions and 212 deletions.
11 changes: 4 additions & 7 deletions TestDLL/TestDLL.plg
Expand Up @@ -6,7 +6,7 @@
--------------------Configuration: TestDLL - Win32 Release--------------------
</h3>
<h3>Command Lines</h3>
Creating temporary file "C:\DOCUME~1\Bart\USTAWI~1\Temp\RSP17.tmp" with contents
Creating temporary file "C:\DOCUME~1\Bart\USTAWI~1\Temp\RSP106.tmp" with contents
[
/nologo /G6 /MT /W3 /Ox /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TESTDLL_EXPORTS" /FR"Release/" /Fp"Release/TestDLL.pch" /YX /Fo"Release/" /Fd"Release/" /FD /c
"D:\Gry\OFP\apihijack.cpp"
Expand All @@ -15,8 +15,8 @@ Creating temporary file "C:\DOCUME~1\Bart\USTAWI~1\Temp\RSP17.tmp" with contents
"D:\Gry\OFP\TestDLL\fdb.cpp"
"D:\Gry\OFP\TestDLL\scripth.cpp"
]
Creating command line "cl.exe @C:\DOCUME~1\Bart\USTAWI~1\Temp\RSP17.tmp"
Creating temporary file "C:\DOCUME~1\Bart\USTAWI~1\Temp\RSP18.tmp" with contents
Creating command line "cl.exe @C:\DOCUME~1\Bart\USTAWI~1\Temp\RSP106.tmp"
Creating temporary file "C:\DOCUME~1\Bart\USTAWI~1\Temp\RSP107.tmp" with contents
[
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib shlwapi.lib Winmm.lib version.lib /nologo /dll /incremental:no /pdb:"..\fwatch.pdb" /machine:I386 /def:".\testdll.def" /out:"..\fwatch.dll" /implib:"..\fwatch.lib"
.\Release\apihijack.obj
Expand All @@ -25,7 +25,7 @@ kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32
.\Release\fdb.obj
.\Release\scripth.obj
]
Creating command line "link.exe @C:\DOCUME~1\Bart\USTAWI~1\Temp\RSP18.tmp"
Creating command line "link.exe @C:\DOCUME~1\Bart\USTAWI~1\Temp\RSP107.tmp"
<h3>Output Window</h3>
Compiling...
apihijack.cpp
Expand All @@ -35,9 +35,6 @@ fdb.cpp
scripth.cpp
Linking...
Creating library ..\fwatch.lib and object ..\fwatch.exp
Creating command line "bscmake.exe /nologo /o"..\TestDLL.bsc" .\Release\apihijack.sbr .\Release\chandler.sbr .\Release\dllmain.sbr .\Release\fdb.sbr .\Release\scripth.sbr"
Creating browse info file...
<h3>Output Window</h3>



Expand Down
9 changes: 9 additions & 0 deletions TestDLL/dllmain.cpp
Expand Up @@ -144,6 +144,15 @@ HANDLE WINAPI NewCreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dw
strcpy((char*) lpFileName, "fwatch\\data\\true.sqf");

}

// On CWA there shouldn't be "Res" folder so we redirect from res\addons to addons
if (global_exe_version[global.exe_index]!=VER_196 && strncmpi(lpFileName,"anims\\..\\Res\\addons\\",20)==0) {
if (len < 511) {
strcpy(global.path_buffer, lpFileName);
shift_buffer_chunk(global.path_buffer, 13, len+1, 4, OPTION_LEFT);
lpFileName = global.path_buffer;
}
}
}


Expand Down
53 changes: 30 additions & 23 deletions TestDLL/file_commands.cpp
Expand Up @@ -316,11 +316,10 @@ case C_FILE_MODLIST:
hFind = FindFirstFile("*", &fd);

if (hFind != INVALID_HANDLE_VALUE) {
StringDynamic Names, Attributes, Versions, Dates;
StringDynamic_init(Names);
StringDynamic_init(Attributes);
StringDynamic_init(Versions);
StringDynamic_init(Dates);
StringDynamic ModNames, ModID, ModCfg;
StringDynamic_init(ModNames);
StringDynamic_init(ModID);
StringDynamic_init(ModCfg);

char sub_folder[][16] = {
"addons",
Expand Down Expand Up @@ -354,9 +353,11 @@ case C_FILE_MODLIST:
DWORD attributes = GetFileAttributes(path2);

if (attributes != -1 && attributes & FILE_ATTRIBUTE_DIRECTORY) {
StringDynamic_append(Names, "]+[\"");
StringDynamic_appendq(Names, fd.cFileName);
StringDynamic_append(Names, "\"");
StringDynamic_append(ModNames, "]+[\"");
StringDynamic_appendq(ModNames, fd.cFileName);
StringDynamic_append(ModNames, "\"");
StringDynamic_append(ModID, "]+[{");
StringDynamic_append(ModCfg, "]+[[");

sprintf(path2, "%s\\__gs_id", fd.cFileName);
FILE *f = fopen(path2, "r");
Expand All @@ -371,21 +372,29 @@ case C_FILE_MODLIST:

while ((item = String_tokenize(data,";",data_pos,OPTION_NONE)).length > 0) {
switch (index) {
case 0 : StringDynamic_appendf(Attributes, "]+[{%s}", item.text); break;
case 1 : StringDynamic_appendf(Versions, "]+[%s", item.text); break;
case 2 : StringDynamic_appendf(Dates, "]+[%s", item.text); break;
case 0 : StringDynamic_appends(ModID, item); break;
case 3 : StringDynamic_appendf(ModCfg, "{%s},", item.text); break;
case 4 : {
if (strcmpi(item.text,"0") == 0)
StringDynamic_append(ModCfg, "false");
else
if (strcmpi(item.text,"1") == 0)
StringDynamic_append(ModCfg, "true");
else
StringDynamic_appendf(ModCfg, "%s", item.text); break;
} break;
default : StringDynamic_appendf(ModCfg, "%s,", item.text); break;
}

index++;
}

fclose(f);
} else {
StringDynamic_append(Attributes, "]+[\"\"");
StringDynamic_append(Versions, "]+[0");
StringDynamic_append(Dates, "]+[0");
}
} else
StringDynamic_append(ModCfg, "0,[],{},0");

StringDynamic_append(ModID, "}");
StringDynamic_append(ModCfg, "]");
break;
}
}
Expand Down Expand Up @@ -464,19 +473,17 @@ case C_FILE_MODLIST:

// Output result
QWrite_err(FWERROR_NONE, 0);
QWritef("[%s],[%s],[%s],[%s],\"%s", Names.text, Attributes.text, Versions.text, Dates.text, custom_filename);
QWritef("[%s],[%s],[%s],\"%s", ModNames.text, ModID.text, ModCfg.text, custom_filename);

FileSize size = DivideBytes(bytes);

unsigned int hash = FNV_BASIS;
hash = fnv1a_hash(hash, Attributes.text, Attributes.length, OPTION_NONE);
hash = fnv1a_hash(hash, Versions.text, Versions.length, OPTION_NONE);
hash = fnv1a_hash(hash, ModCfg.text, ModCfg.length, OPTION_NONE);

QWritef("\",[%f,%f,%f],\"%u\",\"%s\"]", size.bytes, size.kilobytes, size.megabytes, hash, username);
StringDynamic_end(Names);
StringDynamic_end(Attributes);
StringDynamic_end(Versions);
StringDynamic_end(Dates);
StringDynamic_end(ModNames);
StringDynamic_end(ModID);
StringDynamic_end(ModCfg);
} else {
QWrite_err(FWERROR_WINAPI, 2, GetLastError(), username);
QWrite("[],[]]");
Expand Down
1 change: 1 addition & 0 deletions TestDLL/testdll.h
Expand Up @@ -316,6 +316,7 @@ struct GLOBAL_VARIABLES_TESTDLL {
float restore_float[26];
int restore_hud_int[ARRAY_SIZE];
float restore_hud_float[ARRAY_SIZE];
char path_buffer[512];

HANDLE out;
FILE *outf;
Expand Down
27 changes: 12 additions & 15 deletions TestLauncher/TestLauncher.cpp
Expand Up @@ -52,7 +52,7 @@ enum COMMAND_ID {

unsigned long GetIP(char *host);
void ReadUIConfig(char *filename, bool *no_ar, bool *is_custom, float *custom, int *customINT);
int ModfolderMissionsTransfer(char *mod, bool is_dedicated_server, char *player_name);
int ModfolderMissionsTransfer(char *mod, bool is_dedicated_server, char *player_name, int game_version);
void ModfolderMissionsReturn(bool is_dedicated_server);

void FwatchPresence(ThreadArguments *arg);
Expand Down Expand Up @@ -138,6 +138,11 @@ int APIENTRY WinMain(HINSTANCE hInstance,



// Temporary solution for a problem that I've created for myself
if (GetFileAttributes("ColdWarAssault.exe") != 0xFFFFFFFF)
rename("res\\bin\\resource.cpp","res\\bin\\resource_disabled.cpp");


// Create mailslot
SECURITY_DESCRIPTOR sd;
InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
Expand Down Expand Up @@ -520,7 +525,7 @@ void ReadUIConfig(char *filename, bool *no_ar, bool *is_custom, float *custom, i


// Move mission files from the selected modfolder to the game missions folder
int ModfolderMissionsTransfer(char *mod, bool is_dedicated_server, char *player_name)
int ModfolderMissionsTransfer(char *mod, bool is_dedicated_server, char *player_name, int game_version)
{
int file_count = 0;
char filename[64] = "fwatch\\data\\sortMissions";
Expand Down Expand Up @@ -569,6 +574,9 @@ int ModfolderMissionsTransfer(char *mod, bool is_dedicated_server, char *player_
"Users\\"
};

if (game_version != VER_196)
strcpy(folder_dst[4], "Addons");

strcat(folder_dst[5], player_name);
strcat(folder_dst[5], "\\Missions");
strcat(folder_dst[6], player_name);
Expand All @@ -577,11 +585,6 @@ int ModfolderMissionsTransfer(char *mod, bool is_dedicated_server, char *player_
int folder_num = sizeof(folder_src) / sizeof(folder_src[0]);
wchar_t folder_src_w[64] = L"";
wchar_t folder_dst_w[64] = L"";
bool create_res_addons = true;
DWORD attributes = GetFileAttributes("Res\\Addons");

if (attributes != 0xFFFFFFFF && attributes & FILE_ATTRIBUTE_DIRECTORY)
create_res_addons = false;

if (strcmp(player_name,"") == 0)
folder_num -= 2;
Expand Down Expand Up @@ -639,19 +642,13 @@ int ModfolderMissionsTransfer(char *mod, bool is_dedicated_server, char *player_
wcscpy(source_w + mod_len + folder_src_len + 2, fd.cFileName);
wcscpy(destination_w + folder_dst_len + 1, fd.cFileName);

if (i==4 && create_res_addons) {
CreateDirectory("Res", NULL);
CreateDirectory("Res\\Addons", NULL);
create_res_addons = false;
}

WideCharToMultiByte(CP_UTF8,0,source_w,-1,source,1023,NULL,NULL);
WideCharToMultiByte(CP_UTF8,0,destination_w,-1,destination,1023,NULL,NULL);

if (MoveFileExW(source_w, destination_w, 0)) {
file_count++;

if (i >= 5)
if (i >= 5 || (game_version!=VER_196 && i>=4))
fprintf(f, "%s?%s\n", source, destination);
else
fprintf(f, "%s\n", source);
Expand Down Expand Up @@ -1209,7 +1206,7 @@ void FwatchPresence(ThreadArguments *arg)
transfer_missions = false;

for (int i=game_mods_num-1; i>=0; i--)
transfered_missions += ModfolderMissionsTransfer(game_mods[i], arg->is_dedicated_server, player_name);
transfered_missions += ModfolderMissionsTransfer(game_mods[i], arg->is_dedicated_server, player_name, global_exe_version[game_exe_index]);
}

// Refresh master servers (user can change them in the main menu)
Expand Down
11 changes: 4 additions & 7 deletions TestLauncher/TestLauncher.plg
Expand Up @@ -7,28 +7,25 @@
</h3>
<h3>Command Lines</h3>
Creating command line "rc.exe /l 0x409 /fo"Release/script1.res" /d "NDEBUG" "D:\Gry\OFP\TestLauncher\script1.rc""
Creating temporary file "C:\DOCUME~1\Bart\USTAWI~1\Temp\RSP73.tmp" with contents
Creating temporary file "C:\DOCUME~1\Bart\USTAWI~1\Temp\RSP101.tmp" with contents
[
/nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FR"Release/" /Fp"Release/TestLauncher.pch" /YX /Fo"Release/" /Fd"Release/" /FD /c
"D:\Gry\OFP\TestLauncher\TestLauncher.cpp"
]
Creating command line "cl.exe @C:\DOCUME~1\Bart\USTAWI~1\Temp\RSP73.tmp"
Creating temporary file "C:\DOCUME~1\Bart\USTAWI~1\Temp\RSP74.tmp" with contents
Creating command line "cl.exe @C:\DOCUME~1\Bart\USTAWI~1\Temp\RSP101.tmp"
Creating temporary file "C:\DOCUME~1\Bart\USTAWI~1\Temp\RSP102.tmp" with contents
[
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /subsystem:windows /incremental:no /pdb:"..\fwatch.pdb" /machine:I386 /out:"..\fwatch.exe"
.\Release\TestLauncher.obj
.\Release\script1.res
..\fwatch.lib
]
Creating command line "link.exe @C:\DOCUME~1\Bart\USTAWI~1\Temp\RSP74.tmp"
Creating command line "link.exe @C:\DOCUME~1\Bart\USTAWI~1\Temp\RSP102.tmp"
<h3>Output Window</h3>
Compiling resources...
Compiling...
TestLauncher.cpp
Linking...
Creating command line "bscmake.exe /nologo /o"..\TestLauncher.bsc" .\Release\TestLauncher.sbr"
Creating browse info file...
<h3>Output Window</h3>



Expand Down

0 comments on commit ded1d40

Please sign in to comment.