Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable left click to move items #1

Merged
merged 14 commits into from
May 24, 2021
Merged
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ http://gomule.sourceforge.net/ all credits go to Gohanman, Randall, Silospen, co
Original usage docs: https://managedway.dl.sourceforge.net/project/gomule/gomule/R0.31/GoMuleDocs.pdf


#### Usage
1. Install Java Runtime Environment [JRE (Windows x64 exe)](https://www.oracle.com/java/technologies/javase-jre8-downloads.html#license-lightbox) and [instructions](https://docs.oracle.com/goldengate/1212/gg-winux/GDRAD/java.htm#BGBFJHAB)
#### Install
1. Install Java Runtime Environment [JRE (Windows x64 exe)](https://www.oracle.com/java/technologies/javase-jre8-downloads.html#license-lightbox) following the [instructions](https://docs.oracle.com/goldengate/1212/gg-winux/GDRAD/java.htm#BGBFJHAB)
2. Download the repo from [here](https://github.com/pairofdocs/gomule-d2r/archive/refs/heads/main.zip) and unzip it to a convenient location
3. Double click the app in `gomule-d2r/gomule/GoMule.jar`
3. Double click the app at `gomule-d2r-main/gomule/GoMule.jar`


#### Pics
Expand All @@ -21,7 +21,7 @@ Original usage docs: https://managedway.dl.sourceforge.net/project/gomule/gomule


#### Test Save Files
- [Sorc](./savefiles/LamboResu.d2s)
- [Sorc](./savefiles/LamboResu.d2s), [mule](./savefiles/testtt.d2s)


#### Flavie Grail Report
Expand All @@ -32,7 +32,18 @@ Original usage docs: https://managedway.dl.sourceforge.net/project/gomule/gomule


#### In Progress, Debugging
- Moving Items around. Currently Moving items from char to char can be done with D2R's in-game shared stash
- Merc item reading and saving
- Update the data files to v1.14 (test anni and essenses)

#### Fixed
- Moving items between chars ([pic](https://github.com/pairofdocs/gomule-d2r/pull/1#issuecomment-846635551))

#### Backup Save Files
WARNING: Back up important save files when using GoMule!

GoMule automatically creates backup directories in `GoMule.backup/` each `week` by default.
This can be changed to each `day`, `month` or `never`.
Click on Preferences when the app is open to change this setting.


#### Building and Developing
Expand All @@ -46,3 +57,4 @@ Original usage docs: https://managedway.dl.sourceforge.net/project/gomule/gomule
- http://gomule.sourceforge.net/ for the original app
- https://github.com/d07RiV/d07riv.github.io for the save file converter and cracking the item Huffman encoding
- https://github.com/dschu012/d2s for the save file converter and editor
- https://user.xmission.com/~trevin/DiabloIIv1.09_File_Format.shtml for extensive details on the d2s file format
Binary file modified gomule/GoMule.jar
Binary file not shown.
48 changes: 33 additions & 15 deletions gomule/src/gomule/d2s/D2Character.java
Original file line number Diff line number Diff line change
Expand Up @@ -538,12 +538,13 @@ private void readItems() throws Exception{
int lCharEnd = lCharStart;

for (int i = 0; i < num_items; i++){
// TODO: D2R d2s file doesn't have JM for each item. just 1JM at stat and 1 JM at end of item list

// D2R d2s file doesn't have JM for each item. just 1JM at stat and 1 JM at end of item list
int lItemStart = lCharEnd;
//TODO: update lItemStart for following items. use Bit position to start reading items
// update lItemStart for following items. use Bit position to start reading items

D2Item lItem = new D2Item(iFileName, iReader, lItemStart, iCharLevel);
// debugging helper function added to D2Item.java lItem.get_bytes_string()

lLastItemEnd = iReader.get_byte_pos(); // use itemReader for bits position
lCharEnd = lLastItemEnd + 1; // add 1 to get to start nextItem byte, works for 2nd, 3rd, 4th... items

Expand All @@ -555,6 +556,7 @@ private void readItems() throws Exception{
markCharGrid(lItem);
}
}

iItemEnd = lCharEnd;
// TODO: trace through Merc items. disable these for now
int lMercStart = -1;
Expand Down Expand Up @@ -1017,8 +1019,8 @@ public boolean unmarkCharGrid(D2Item i){
col = (int) i.get_col();
width = (int) i.get_width();
height = (int) i.get_height();
if ((row + height) > 8)return false;
if ((col + width) > 6)return false;
if ((row + height) > 10)return false; // orig > 8
if ((col + width) > 10)return false; // orig > 6
for (j = row; j < row + height; j++){
for (k = col; k < col + width; k++)
iStashGrid[j][k] = false;
Expand Down Expand Up @@ -1261,7 +1263,7 @@ public boolean checkMercPanel(int panel, int x, int y, D2Item pItem){
return true;
}

public int getCharItemIndex(int panel, int x, int y){
public int getCharItemIndex(int panel, int x, int y){ // iRow, iCol are input
if (panel == BODY_BELT_CONTENT){
for (int i = 0; i < iCharItems.size(); i++){
D2Item temp_item = (D2Item) iCharItems.get(i);
Expand All @@ -1284,9 +1286,11 @@ public int getCharItemIndex(int panel, int x, int y){
for (int i = 0; i < iCharItems.size(); i++){
D2Item temp_item = (D2Item) iCharItems.get(i);
if (temp_item.get_panel() == panel) {
int row = temp_item.get_col();
int col = temp_item.get_row();
if (x >= row && x <= row + temp_item.get_width() - 1 && y >= col && y <= col + temp_item.get_height() - 1)return i;
int col = temp_item.get_col();
int row = temp_item.get_row();
if ((x >= col) && (x <= col + temp_item.get_width() - 1) && (y >= row) && (y <= row + temp_item.get_height() - 1)) {
return i;
}
}
}
}
Expand All @@ -1302,8 +1306,8 @@ public int getCorpseItemIndex(int panel, int x, int y){
}
}
}else if (panel >= 10){
for (int i = 0; i < iCorpseItems.size(); i++){
D2Item temp_item = (D2Item) iCorpseItems.get(i);
for (int i = 0; i < iCharItems.size(); i++){
D2Item temp_item = (D2Item) iCharItems.get(i);
if (temp_item.get_location() != 0 && temp_item.get_location() != 2){
if (temp_item.get_panel() == 0){
if (temp_item.get_body_position() == panel - 10){
Expand Down Expand Up @@ -1345,9 +1349,11 @@ public void saveInternal(D2Project pProject)
// entire item list and insert it into
// the open file in place of its current item list
int lCharSize = 0;

for (int i = 0; i < iCharItems.size(); i++){
lCharSize += ((D2Item) iCharItems.get(i)).get_bytes().length;
}

if ( iCharCursorItem != null ){
lCharSize += iCharCursorItem.get_bytes().length;
}
Expand All @@ -1362,33 +1368,43 @@ public void saveInternal(D2Project pProject)
int lPos = 0;
System.arraycopy(iBeforeStats, 0, lNewbytes, lPos, iBeforeStats.length);
lPos += iBeforeStats.length;

System.arraycopy(lWritenBytes, 0, lNewbytes, lPos, lWritenBytes.length);
lPos += lWritenBytes.length;

System.arraycopy(iBeforeItems, 0, lNewbytes, lPos, iBeforeItems.length);
lPos += iBeforeItems.length;
int lCharItemCountPos = lPos - 2;
int lMercItemCountPos = -1;

int lCharItemCountPos = lPos - 2; // <<<<< is this correct for D2R? subtract 2 for JM ?
int lMercItemCountPos = -1; // <<<<< is this correct for D2R?
for (int i = 0; i < iCharItems.size(); i++){
byte[] item_bytes = ((D2Item) iCharItems.get(i)).get_bytes();
System.arraycopy(item_bytes, 0, lNewbytes, lPos, item_bytes.length);

lPos += item_bytes.length;
}
if ( iCharCursorItem != null ){
byte[] item_bytes = iCharCursorItem.get_bytes();
// debug print the byte array[]. items end on byte. beginning 4bytes are item flags.
// are the item bytes already in Huffman code? since bytes are read and addItem is used
System.arraycopy(item_bytes, 0, lNewbytes, lPos, item_bytes.length);
lPos += item_bytes.length;
}
if (hasMerc()){
// Should this be enabled? I never read the merc's items yet. so don't write anything
// Merc start jf JM ... and end is kf. so lMercItemCountPos = lPos + 2 --> 4A(J) 4D(M) 00 00 is the corpse.
System.arraycopy(iBetweenItems, 0, lNewbytes, lPos, iBetweenItems.length);
lPos += iBetweenItems.length;
lMercItemCountPos = lPos - 2;
lMercItemCountPos = lPos + 2; // lPos - 2 <<<<< is this correct for D2R? NO! found it! should be +2, skip the 2'JM' chars

for (int i = 0; i < iMercItems.size(); i++){
byte[] item_bytes = ((D2Item) iMercItems.get(i)).get_bytes();
System.arraycopy(item_bytes, 0, lNewbytes, lPos, item_bytes.length);
lPos += item_bytes.length;
}
}
if (iAfterItems.length > 0){
// This array is created up at the top, where items are read from the file
System.arraycopy(iAfterItems, 0, lNewbytes, lPos, iAfterItems.length);
}
iReader.setBytes(lNewbytes); // iReader.getFileContent()
Expand All @@ -1400,7 +1416,9 @@ public void saveInternal(D2Project pProject)
iReader.write(lCharItemsCount, 16);
if (hasMerc()){
iReader.set_byte_pos(lMercItemCountPos);
iReader.write(iMercItems.size(), 16);
iReader.write(iMercItems.size(), 16); // <<<<<<<<<< could this be the issue?, writin 00 for merc itemssize?. Yes. this was writing 0x00 at the last item byte.
// Merc item reading should be fixed and this can be enabled and debugged.
// For now. 0x00 is written before JM _ _ jfJM (start of Merc). the corpse bytes
}
// get all the bytes
iReader.set_byte_pos(0);
Expand Down
Loading