Skip to content
Merged
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
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "re0box"
version = "0.5.0"
version = "0.5.2"
authors = ["descawed <re0box@descawed.com>"]
edition = "2021"
description = "An item box mod for Resident Evil 0"
Expand All @@ -20,12 +20,12 @@ panic = "abort"

[dependencies]
anyhow = "1.0"
binrw = "0.14.1"
binrw = "0.15.0"
configparser = "3.1"
log = "0.4"
memchr = "2.7.4"
memchr = "2.8.0"
simplelog = "0.12"
windows = { version = "0.59.0", features = [ "Win32_Foundation", "Win32_System_Diagnostics_Debug", "Win32_System_Memory", "Win32_System_ProcessStatus", "Win32_System_Kernel", "Win32_System_SystemServices", "Win32_System_Threading" ] }
windows = { version = "0.62.2", features = [ "Win32_Foundation", "Win32_System_Diagnostics_Debug", "Win32_System_Memory", "Win32_System_ProcessStatus", "Win32_System_Kernel", "Win32_System_SystemServices", "Win32_System_Threading" ] }

[build-dependencies]
winresource = "0.1"
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,14 @@ This section controls logging behavior.
game folder, you can also use an absolute path for a different location, such as C:\Users\Bob\Documents\re0box.log.

## Uninstall
Delete scripts\re0box.asi from the Resident Evil 0 folder. None of the other mod files will have any effect once that's
gone, but if you want to purge everything, this is the full list of files added by the mod:
Run re0box_uninstall.bat to uninstall the mod. If for some reason you want to uninstall manually, this is the full list
of files added by the mod:
- dinput8.dll (note that other mods may need this file. if you have anything in your scripts folder besides re0box.asi,
you should leave this one alone.)
- re0box.ini
- re0box.log
- re0box_readme.txt
- re0box_uninstall.bat
- nativePC\arc\message\msg_chS_box.arc
- nativePC\arc\message\msg_chT_box.arc
- nativePC\arc\message\msg_eng_box.arc
Expand Down
144 changes: 144 additions & 0 deletions re0box_uninstall.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
@echo off
setlocal EnableDelayedExpansion

echo ========================================
echo re0box uninstaller
echo ========================================
echo.
echo This will delete the following files and folders:
echo - scripts\re0box.asi
echo - dinput8.dll (only if scripts folder contains no other ASI files)
echo - re0box.ini
echo - re0box.log
echo - re0box_readme.txt
echo - nativePC\arc\message\msg_chS_box.arc
echo - nativePC\arc\message\msg_chT_box.arc
echo - nativePC\arc\message\msg_eng_box.arc
echo - nativePC\arc\message\msg_fre_box.arc
echo - nativePC\arc\message\msg_ger_box.arc
echo - nativePC\arc\message\msg_ita_box.arc
echo - nativePC\arc\message\msg_jpn_box.arc
echo - nativePC\arc\message\msg_spa_box.arc
echo.
echo WARNING: If you have saved with the mod installed, uninstalling
echo will cause all item boxes to be deleted from all saves.
echo.
choice /C YN /N /M "Are you sure you want to uninstall? (Y/N): "
if errorlevel 2 (
echo Uninstall cancelled.
pause
exit /b 0
)

echo.
echo Starting uninstall...
echo.

REM Delete the main ASI file
if exist "scripts\re0box.asi" (
del "scripts\re0box.asi"
if !errorlevel! equ 0 (
echo Deleted: scripts\re0box.asi
) else (
echo ERROR: Failed to delete scripts\re0box.asi
)
) else (
echo Not found: scripts\re0box.asi
)

REM Check if dinput8.dll should be deleted
set "delete_dinput8=1"
if exist "scripts\" (
for /f "delims=" %%f in ('dir /b /a-d "scripts\*.asi" 2^>nul') do (
echo Found other ASI file: scripts\%%f
set "delete_dinput8=0"
)
)

REM Check if scripts folder is empty and delete it if so
if exist "scripts\" (
dir /b "scripts\" | findstr "^" >nul
if !errorlevel! neq 0 (
rmdir "scripts"
if exist "scripts\" (
echo ERROR: Failed to delete scripts folder
) else (
echo Deleted empty folder: scripts
)
) else (
echo Keeping scripts folder ^(not empty^)
)
)

if "%delete_dinput8%"=="1" (
if exist "dinput8.dll" (
del "dinput8.dll"
if !errorlevel! equ 0 (
echo Deleted: dinput8.dll
) else (
echo ERROR: Failed to delete dinput8.dll
)
) else (
echo Not found: dinput8.dll
)
) else (
echo Skipping dinput8.dll ^(other ASI files detected in scripts folder^)
)

REM Delete config and log files
if exist "re0box.ini" (
del "re0box.ini"
if !errorlevel! equ 0 (
echo Deleted: re0box.ini
) else (
echo ERROR: Failed to delete re0box.ini
)
) else (
echo Not found: re0box.ini
)

if exist "re0box.log" (
del "re0box.log"
if !errorlevel! equ 0 (
echo Deleted: re0box.log
) else (
echo ERROR: Failed to delete re0box.log
)
) else (
echo Not found: re0box.log
)

if exist "re0box_readme.txt" (
del "re0box_readme.txt"
if !errorlevel! equ 0 (
echo Deleted: re0box_readme.txt
) else (
echo ERROR: Failed to delete re0box_readme.txt
)
) else (
echo Not found: re0box_readme.txt
)

REM Delete message arc files
set "msg_files=msg_chS_box.arc msg_chT_box.arc msg_eng_box.arc msg_fre_box.arc msg_ger_box.arc msg_ita_box.arc msg_jpn_box.arc msg_spa_box.arc"
for %%m in (%msg_files%) do (
if exist "nativePC\arc\message\%%m" (
del "nativePC\arc\message\%%m"
if !errorlevel! equ 0 (
echo Deleted: nativePC\arc\message\%%m
) else (
echo ERROR: Failed to delete nativePC\arc\message\%%m
)
) else (
echo Not found: nativePC\arc\message\%%m
)
)

echo.
echo Uninstall complete!
echo This uninstaller will now delete itself.
echo.
pause

REM Self-delete using a temporary batch file
(goto) 2>nul & del "%~f0"
61 changes: 53 additions & 8 deletions src/inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,7 @@ impl ItemBox {
None => self.items.len(),
};

// this shouldn't happen, but if somehow we ended up with an empty slot in the
// middle of the box, just delete it
if self.items[range_start].is_empty() {
self.items.remove(range_start);
} else {
self.items[range_start..range_end].rotate_left(1);
}
self.items[range_start..range_end].rotate_left(1);

check_start = range_end;
} else {
Expand Down Expand Up @@ -259,10 +253,13 @@ impl ItemBox {
// the view
self.items.swap(box_index - 1, box_index + 1);
}
// fix any misaligned two-slot items that might have been introduced by the insertion
self.fix_misaligned(box_index + 1);
self.update_view();
if self.view.is_broken() {
log::warn!(
"View is in a broken state after making room for two-slot item: {:?}",
"View is in a broken state after making room for two-slot item at index {}: {:?}",
index,
self
);
}
Expand Down Expand Up @@ -434,6 +431,54 @@ mod tests {
assert!(view.items[BAG_SIZE - 1].is_empty());
}

#[test]
fn make_room_for_double_with_two_slot_at_end() {
let mut item_box = ItemBox {
is_open: true,
items: vec![
Item { id: 5, count: 0 },
Item { id: 180, count: 1 },
Item { id: 38, count: 3 },
Item { id: 2, count: 1 },
Item { id: 104, count: 1 },
Item { id: 180, count: 1 },
Item { id: 2, count: 1 },
Item { id: 48, count: 1 },
Item { id: 3, count: 0 },
Item { id: 36, count: 6 },
Item { id: 35, count: 16 },
Item { id: 10, count: 8 },
Item { id: 53, count: 1 },
Item { id: 43, count: 1 },
Item { id: 43, count: 1 },
Item { id: 43, count: 1 },
Item { id: 55, count: 12 },
Item { id: 34, count: 1 },
Item { id: 39, count: 12 },
Item { id: 14, count: 3 },
Item { id: 53, count: 1 }
],
index: 0,
view: Bag {
unknown00: 0,
items: [
Item { id: 5, count: 0 },
Item { id: 180, count: 1 },
Item { id: 38, count: 3 },
Item { id: 2, count: 1 },
Item { id: 104, count: 1 },
Item { id: 180, count: 1 }
],
personal_item: Item { id: 0, count: 0 },
equipped_item_index: -1
}
};
assert!(item_box.view.is_valid());

item_box.make_room_for_double(2);
assert!(!item_box.view.is_broken());
}

#[test]
fn scroll() {
let mut item_box = ItemBox::new();
Expand Down
Loading