Proper Saving a custom .bin file client-side
Moderators: Nefarius, Havvoric
- weapon-x
- Arch-Angel
- Posts: 1047
- Joined: Wed Mar 18, 2009 4:52 am
- Location: Mindanao, Philippines
- Contact:
Proper Saving a custom .bin file client-side
howdy all, yep... sorry to disappoint you guys but i am still alive (yay !)
anyhow, just currently went back to modding, so yeah...
i have lots of ideas that i wished to see in D2, however a lot of stuff requires custom data saving for each client.
i am currently able to generate a custom binary file with the following format (save\%playername%.bin), however i seemed to encounter a problem. i temporarily call the custom .bin generation code along with the frontpanel drawing code, thinking since its client-sided only (i am almost certain that this will only be called client-side so i put it there), however when i started a multiplayer session on two test PCs, the custom .bin file is only generated on the host PC, which doesn't make any sense
any ideas?
anyhow, just currently went back to modding, so yeah...
i have lots of ideas that i wished to see in D2, however a lot of stuff requires custom data saving for each client.
i am currently able to generate a custom binary file with the following format (save\%playername%.bin), however i seemed to encounter a problem. i temporarily call the custom .bin generation code along with the frontpanel drawing code, thinking since its client-sided only (i am almost certain that this will only be called client-side so i put it there), however when i started a multiplayer session on two test PCs, the custom .bin file is only generated on the host PC, which doesn't make any sense
any ideas?
" It's not the size of the dog in the fight, it's the size of the fight in the dog. "
~Mark Twain
~Mark Twain
- Necrolis
- Throne
- Posts: 9125
- Joined: Sat Mar 25, 2006 1:22 pm
- Location: The Land of the Dead
- Contact:
Re: Proper Saving a custom .bin file client-side
Is it an output from txt compilation, or a custom format? Where are you hooking to create the file?
Netiquette, Do you USE it?!?! | Nefarius' Fixed TXT Files | Terms Of Service
Blackened | Day of Death | D2GFEx
"What was yours is mine. Your land, your people, and now your life." - Lim-Dul, the Necromancer
Judgement is Final, Death is Eternal
- weapon-x
- Arch-Angel
- Posts: 1047
- Joined: Wed Mar 18, 2009 4:52 am
- Location: Mindanao, Philippines
- Contact:
Re: Proper Saving a custom .bin file client-side
its a custom .bin file, and was hooked on d2client (front-panel) drawing
*sorry sir, took some time to reply, haven't got the chance to use the internet these past few days
will post the code as soon as possible.
edit:
Here is the code i used, its actually just a simple stream. This is intended to save custom menu settings per character.
Code: Select all
BOOL __stdcall D2REVOLUTION_WriteCustomSaveFile(D2UnitStrc* pUnit)
{
MyRecord pRecord;
ZeroMemory(&pRecord, sizeof(MyRecord));
strcpy(pRecord.szName, pUnit->pPlayerData->szName); //save name
pRecord.nLevel = D2COMMON_GetStat(pUnit, STAT_LEVEL, 0); //save level
pRecord.OptionA = DisplayHPBarFlag;
pRecord.OptionB = DisplayMPBarFlag;
pRecord.OptionC = DisplayStamBarFlag;
pRecord.OptionD = DisplayCritterNameFlag;
pRecord.OptionE = DisplayAllyNPCNameFlag;
pRecord.OptionF = DisplayEnemyMonsterNameFlag;
pRecord.OptionG = DisplayMonsterInfoTabFlag;
pRecord.OptionH = DisplaySuperUniqueHPBarFlag;
pRecord.OptionI = DisplayFullArmorSpriteFlag;
pRecord.OptionJ = UseHeadColorPaletteFlag;
pRecord.OptionK = DisplayClientGoldAutopickFlag;
pRecord.OptionL = DisplayHPMPValFlag;
pRecord.OptionM = DrawInvItemHighlightFlag;
pRecord.OptionN = DrawMouseOverInvItemHighlightFlag;
pRecord.OptionO = DrawEquippedItemHighlightFlag;
pRecord.OptionP = DrawMouseOverEquipmentItemHighlightFlag;
pRecord.OptionQ = DrawQuantityValueOverItemGfxFlag;
pRecord.OptionR = DrawItemCompareFlag;
char FileName[128];
sprintf_s(FileName, sizeof(FileName),"save/%s.bin",pUnit->pPlayerData->szName);
ofstream outbal(FileName, ios::out | ios::binary); //filename
if(!outbal)
{
return FALSE;
}
outbal.write((char *) &pRecord, sizeof(struct MyRecord));
outbal.close();
return TRUE;
}
" It's not the size of the dog in the fight, it's the size of the fight in the dog. "
~Mark Twain
~Mark Twain
- Necrolis
- Throne
- Posts: 9125
- Joined: Sat Mar 25, 2006 1:22 pm
- Location: The Land of the Dead
- Contact:
Re: Proper Saving a custom .bin file client-side
AH, so you are writing save files; in this case you need to be careful of where you get the data from. For UI configs, this isn't an issue because the data is all client side.
The first issue I can see is the save path; D2 isn't always launched from the folder where the save file is stored; I suggest you use the fog ordinal (#10115) to get the current save path, this will also ensure that the save folder exists (remember, Windows file paths are case sensitive).
When you need to save stuff other than client configs; you need the server to write the savefile to a memory buffer and stream that to the client for writing to the harddisk (and the for the client to stream it to the server when a character is loaded), this is why its easier to just hijack the last section of the save file (the iron golem) or one of the simpler sections (like skills) and inject all the custom data in there.
The first issue I can see is the save path; D2 isn't always launched from the folder where the save file is stored; I suggest you use the fog ordinal (#10115) to get the current save path, this will also ensure that the save folder exists (remember, Windows file paths are case sensitive).
Code: Select all
char szSavePath[256];
char szFilePath[256];
D2GetSavePath(szSavePath,sizeof(szSavePath));
sprintf_s(szFilePath,sizeof(szFilePath),"%s\\%s.uiconfig",szSavePath,pUnit->pPlayerData->szName);
Netiquette, Do you USE it?!?! | Nefarius' Fixed TXT Files | Terms Of Service
Blackened | Day of Death | D2GFEx
"What was yours is mine. Your land, your people, and now your life." - Lim-Dul, the Necromancer
Judgement is Final, Death is Eternal
- weapon-x
- Arch-Angel
- Posts: 1047
- Joined: Wed Mar 18, 2009 4:52 am
- Location: Mindanao, Philippines
- Contact:
Re: Proper Saving a custom .bin file client-side
i was thinking of using custom S>C packets for saving important data, client-side. C>S packets for validation/checks and other stuff. I will look into hijacking the last section of the save file too, as i am not quite familiar with this routine yetNecrolis wrote: ↑Wed Dec 05, 2018 11:13 amAH, so you are writing save files; in this case you need to be careful of where you get the data from. For UI configs, this isn't an issue because the data is all client side.
The first issue I can see is the save path; D2 isn't always launched from the folder where the save file is stored; I suggest you use the fog ordinal (#10115) to get the current save path, this will also ensure that the save folder exists (remember, Windows file paths are case sensitive).
When you need to save stuff other than client configs; you need the server to write the savefile to a memory buffer and stream that to the client for writing to the harddisk (and the for the client to stream it to the server when a character is loaded), this is why its easier to just hijack the last section of the save file (the iron golem) or one of the simpler sections (like skills) and inject all the custom data in there.Code: Select all
char szSavePath[256]; char szFilePath[256]; D2GetSavePath(szSavePath,sizeof(szSavePath)); sprintf_s(szFilePath,sizeof(szFilePath),"%s\\%s.uiconfig",szSavePath,pUnit->pPlayerData->szName);
thanks for the insight sir, will try to test-out using fog ordinal #10115 first thing
" It's not the size of the dog in the fight, it's the size of the fight in the dog. "
~Mark Twain
~Mark Twain