Skip to content

Commit

Permalink
fix: read notes
Browse files Browse the repository at this point in the history
- house handler now has a different way to load and save settings where it tries to recove partially if old configs are not valid anymore
- new house objects were added (chapel altars)
- RI Setup is not setup by TBaseScript anymore when using `SCRIPT_GUI`

Old house configs are probably gonna be useless. Sorry. The file is kept under the name `.old` but you can't really use it anymore.
  • Loading branch information
Torwent committed Dec 27, 2024
1 parent 244ed3e commit 8ba339a
Show file tree
Hide file tree
Showing 5 changed files with 172 additions and 62 deletions.
83 changes: 76 additions & 7 deletions optional/handlers/house/house.simba
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ begin
Self.Teleports[teleport].SetupUpText(teleport.GetUpText());
Self.Teleports[teleport].Finder := teleport.GetFinder();
Self.Teleports[teleport].Walker := @Self.Walker;

if teleport in [EHouseTeleport.DIGSITE, EHouseTeleport.XERIC] then
Self.Teleports[teleport].Filter.Finder := False;
end;

procedure THouseHandler._SetupObject(obj: EHouseObject; coordinate: TPoint; rotation: Int32);
Expand All @@ -123,6 +126,9 @@ begin
Self.Objects[obj].SetupUpText(obj.GetUpText());
Self.Objects[obj].Finder := obj.GetFinder();
Self.Objects[obj].Walker := @Self.Walker;

if obj in [EHouseObject.GLORY, EHouseObject.MYTH_CAPE, EHouseObject.LEFT_AMULET, EHouseObject.RIGHT_AMULET] then
Self.Objects[obj].Filter.Finder := False;
end;

procedure THouseHandler.SetupObjects();
Expand Down Expand Up @@ -776,6 +782,13 @@ begin
end;
end;

'larder_combobox':
begin
room.Objects -= KITCHEN_LARDERS;
if index <> 0 then
room.Objects += EHouseObject.LARDER + index-1;
end;

'repair_stand_combobox':
begin
case index of
Expand Down Expand Up @@ -807,14 +820,21 @@ begin
room.Objects += EHouseObject.OAK_LECTERN + index-1;
end;

'prayer_altar_combobox':
'chapel_altar_combobox':
begin
case index of
0: room.Objects := [];
1: room.Objects := [EHouseObject.PRAYER_ALTAR];
end;
room.Objects -= CHAPEL_ALTARS;
if index <> 0 then
room.Objects += EHouseObject.OAK_ALTAR + index-1;
end;

'burners_combobox':
begin
room.Objects -= CHAPEL_BURNERS;
if index <> 0 then
room.Objects += CHAPEL_BURNERS;
end;


'left_portal_combobox':
begin
room.Objects -= [EHouseObject.LEFT_PORTAL];
Expand Down Expand Up @@ -915,6 +935,32 @@ begin
end;

procedure TScriptForm.RefreshObjectsPanel(panel: TPanel; room: THouseRoom);
function SetCount(var val): Int32;
var
i,j: Int32;
tmp: array [0..31] of Byte;
begin
Move(val, tmp, 32);
Result := 0;
for j:=0 to 31 do
for i:=0 to 7 do
if (tmp[j] and (1 shl i)) <> 0 then
Inc(Result);
end;

function SetFirst(var val): Int32;
var
i,j: Int32;
tmp: array [0..31] of Byte;
begin
Move(val, tmp, 32);
Result := -1;
for j:=0 to 31 do
for i:=0 to 7 do
if (tmp[j] and (1 shl i)) <> 0 then
Exit(j*8+i);
end;

var
combobox: TLabeledComboBox;
teleports: TStringArray;
Expand All @@ -936,6 +982,15 @@ begin
combobox.ComboBox.setOnChange(@Self.POHObjectUpdate);
end;

EHouseRoom.KITCHEN:
begin
combobox.Create(panel, 'Larder:', 'Does this room have a larder?', [0,0],[166,50], True);
combobox.AddItemArray(['None', 'Normal', 'Oak', 'Teak']);
combobox.SetName('larder');
combobox.SetItemIndex(SetCount(room.Objects));
combobox.ComboBox.setOnChange(@Self.POHObjectUpdate);
end;

EHouseRoom.WORKSHOP:
begin
combobox.Create(panel, 'Repair armour stand:', 'Does this room have an armour stand?', [0,0],[166,50], True);
Expand Down Expand Up @@ -984,9 +1039,22 @@ begin
EHouseRoom.CHAPEL:
begin
combobox.Create(panel, 'Altar:', 'Does this room have an altar?', [0,0],[166,50], True);
combobox.AddItemArray(['None', 'Oak', 'Teak', 'Cloth', 'Mahogany', 'Limestone', 'Marble', 'Gilded']);
combobox.SetName('chapel_altar');

tmp := room.Objects - CHAPEL_BURNERS;
if SetCount(tmp) <> 1 then
combobox.SetItemIndex(0)
else
combobox.SetItemIndex(SetFirst(tmp) - Ord(EHouseObject.OAK_ALTAR) + 1);
combobox.ComboBox.setOnChange(@Self.POHObjectUpdate);

combobox := [];
combobox.Create(panel, 'Incense burners:', 'Does this room have an incense burner?', [0,50],[166,50], True);
combobox.AddItemArray(['No', 'Yes']);
combobox.SetName('prayer_altar');
combobox.SetItemIndex(SetCount(room.Objects));
combobox.SetName('burners');
tmp := room.Objects - CHAPEL_ALTARS;
combobox.SetItemIndex(Min(1, SetCount(tmp)));
combobox.ComboBox.setOnChange(@Self.POHObjectUpdate);
end;

Expand Down Expand Up @@ -1065,6 +1133,7 @@ begin
combobox.SetName('pool');

tmp := room.Objects - SUPERIOR_GARDEN_TELEPORTS;

if SetCount(tmp) <> 1 then
combobox.SetItemIndex(0)
else
Expand Down
73 changes: 44 additions & 29 deletions optional/handlers/house/housemap.simba
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,13 @@ var
o: EHouseObject;
troom: TTeleportRoom;
begin
Result := '[' + ToStr(Ord(Self.Location)) + ' ' + ToStr(Ord(Self.Decoration)) +']';
Result := '[';
Result += '5 ';
Result += ToStr(Ord(High(EHouseObject))) + ' ';
Result += ToStr(Ord(High(EHouseTeleport))) + ' ';
Result += ToStr(Ord(Self.Location)) + ' ' + ToStr(Ord(Self.Decoration));
Result += ']';

for idx.Y := 0 to Self.AMOUNT-1 do
for idx.X := 0 to Self.AMOUNT-1 do
begin
Expand Down Expand Up @@ -514,31 +520,34 @@ var
i, j: Int32;
room: THouseRoom;
main, portals: String;
skipObjects: Boolean;
begin
elements := MultiBetween(DecompressString(Base64Decode(s)), '[', ']');
if elements = [] then Exit;

values := Explode(' ', elements[0]);

if elements <> [] then
//validate something didn't change that made the config unparseable
if (Length(values) < 5) or (StrToInt(values[0]) <> Length(values)) then
begin
values := Explode(' ', elements[0]);
case Length(values) of
0:
begin
Self.Location := EHouseLocation(0);
Self.SetColors(EHouseDecoration(0));
end;
1:
begin
Self.Location := EHouseLocation(StrToInt(values[0]));
Self.SetColors(EHouseDecoration(0));
end;
2:
begin
Self.Location := EHouseLocation(StrToInt(values[0]));
Self.SetColors(EHouseDecoration(StrToInt(values[1])));
end;
end;
MessageDlg('House Loader', 'Error loading old house layout.' + LineEnding + 'This could be because it was updated and the old version is not compatible anymore.' + LineEnding + LineEnding + 'Your house layout has been reset!', TMsgDlgType.mtError, [mbOk]);
CopyFile(Self.Config.Path, Self.Config.Path + '.old', True);
Self.Location := EHouseLocation.RIMMINGTON;
Self.SetColors(EHouseDecoration.WOOD);
Self.DrawMap([EHouseRoom.GARDEN, 0, [EHouseObject.EXIT]], [Self.AMOUNT div 2, Self.AMOUNT div 2]);
Exit;
end;

//validate EHouseObjects and EHouseTeleport didn't change
skipObjects := StrToInt(values[1]) <> Ord(High(EHouseObject));
skipObjects := skipObjects or (StrToInt(values[2]) <> Ord(High(EHouseTeleport)));

if skipObjects then
MessageDlg('House Loader', 'Error loading old house layout.' + LineEnding + 'This could be because it was updated and the old version is not compatible anymore.' + LineEnding + LineEnding + 'Your house layout remains but your will need to reconfigure your objects!', TMsgDlgType.mtError, [mbOk]);

Self.Location := EHouseLocation(StrToInt(values[3]));
Self.SetColors(EHouseDecoration(StrToInt(values[4])));

for i := 2 to High(elements) do
begin
if elements[i].Contains(' (') then
Expand All @@ -558,21 +567,27 @@ begin
room.Room := EHouseRoom(StrToInt(values[2]));
room.Rotation := StrToInt(values[3]);

room.Objects := [];
for j := 4 to High(values) do
room.Objects += EHouseObject(StrToInt(values[j]));
if not skipObjects then
begin
room.Objects := [];
for j := 4 to High(values) do
room.Objects += EHouseObject(StrToInt(values[j]));
end;

case room.Room of
EHouseRoom.UNKNOWN: ;
EHouseRoom.PORTAL_CHAMBER, EHouseRoom.SUPERIOR_GARDEN, EHouseRoom.PORTAL_NEXUS:
begin
values := Explode(' ', portals);
if not skipObjects then
begin
values := Explode(' ', portals);

Self.TeleportRooms[idx.Y, idx.X] := [
EHouseTeleport(StrToInt(values[0])),
EHouseTeleport(StrToInt(values[1])),
EHouseTeleport(StrToInt(values[2]))
];
Self.TeleportRooms[idx.Y, idx.X] := [
EHouseTeleport(StrToInt(values[0])),
EHouseTeleport(StrToInt(values[1])),
EHouseTeleport(StrToInt(values[2]))
];
end;

Self.DrawMap(room, idx);
end;
Expand Down
61 changes: 43 additions & 18 deletions optional/handlers/house/houseutils.simba
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,16 @@ EHouseObject = (
*)
EHouseObject = (
EXIT, REPAIR_STAND, SERVANT_BAG,
LARDER, OAK_LARDER, TEAK_LARDER,
GLORY, MYTH_CAPE,

OAK_LECTERN, EAGLE_LECTERN, DEMON_LECTERN, TEAK_EAGLE_LECTERN,
TEAK_DEMON_LECTERN, MAHOGANY_EAGLE_LECTERN, MAHOGANY_DEMON_LECTERN,
MARBLE_LECTERN,

PRAYER_ALTAR,
LEFT_BURNER, RIGHT_BURNER,
OAK_ALTAR, TEAK_ALTAR, CLOTH_ALTAR, MAHOGANY_ALTAR, LIMESTONE_ALTAR,
MARBLE_ALTAR, GILDED_ALTAR,

LEFT_PORTAL, MIDDLE_PORTAL, RIGHT_PORTAL,

Expand Down Expand Up @@ -193,7 +196,8 @@ function EHouseObject.GetSize(): Vector3;
begin
case Self of
EHouseObject.EXIT: Result := [2,2,8];
EHouseObject.PRAYER_ALTAR: Result := [2,1,4];
EHouseObject.OAK_ALTAR..EHouseObject.GILDED_ALTAR: Result := [2,1,4];
EHouseObject.LARDER..EHouseObject.TEAK_LARDER: Result := [1.7,1.7,7];

EHouseObject.LEFT_PORTAL, EHouseObject.RIGHT_PORTAL: Result := [0.6,1.7,7];
EHouseObject.MIDDLE_PORTAL: Result := [1.7,0.6,7];
Expand All @@ -212,12 +216,16 @@ begin
EHouseObject.RESTORATION_POOL..EHouseObject.ORNATE_POOL: Result := [1.5,1.5,4];

EHouseObject.NEXUS: Result := [2,2,8];
EHouseObject.LEFT_AMULET, EHouseObject.RIGHT_AMULET: Result := [0.7,0.7,7];

EHouseObject.BASIC_JEWELLERY_BOX, EHouseObject.FANCY_JEWELLERY_BOX,
EHouseObject.ORNATE_JEWELLERY_BOX: Result := [0.7,0.7,5];

EHouseObject.CAPE_HANGER: Result := [0.5, 0.5 ,5];
end;

if Self = EHouseObject.LEFT_AMULET then
WriteLn Result;
end;

function EHouseObject.GetOffset(): TPoint;
Expand All @@ -230,11 +238,8 @@ begin
//Also these are quite deorganized atm. Sorry.
case Self of
EHouseObject.EXIT: Result := Point(14,16); //by taze
EHouseObject.PRAYER_ALTAR: Result := Point(16,16); //todo: aprox placeholder...

EHouseObject.SPIRIT_TREE..EHouseObject.SPIRITUAL_FAIRY_TREE: Result := Point(14, 17);

EHouseObject.NEXUS: Result := Point(14,16);
EHouseObject.LARDER..EHouseObject.TEAK_LARDER: Result := Point(26,28);
EHouseObject.OAK_ALTAR..EHouseObject.GILDED_ALTAR: Result := Point(16,16); //todo: aprox placeholder...

EHouseObject.LEFT_PORTAL: Result := Point(0,16);
EHouseObject.MIDDLE_PORTAL: Result := Point(15,1);
Expand All @@ -251,6 +256,11 @@ begin
EHouseObject.OAK_LECTERN..EHouseObject.MARBLE_LECTERN: Result := Point(8, 23); //todo: aprox placeholder...

EHouseObject.RESTORATION_POOL..EHouseObject.ORNATE_POOL: Result := Point(26,4);
EHouseObject.SPIRIT_TREE..EHouseObject.SPIRITUAL_FAIRY_TREE: Result := Point(14, 17);

EHouseObject.NEXUS: Result := Point(14,16);
EHouseObject.LEFT_AMULET: Result := Point(4,31);
EHouseObject.RIGHT_AMULET: Result := Point(24,31);

EHouseObject.BASIC_JEWELLERY_BOX..EHouseObject.ORNATE_JEWELLERY_BOX: Result := Point(24,24);

Expand Down Expand Up @@ -288,19 +298,13 @@ begin
EHouseObject.LEFT_PORTAL..EHouseObject.RIGHT_PORTAL, EHouseObject.LEFT_AMULET,EHouseObject.RIGHT_AMULET: ;

EHouseObject.EXIT: Result := ['Enter', 'Portal'];
EHouseObject.LARDER..EHouseObject.TEAK_LARDER: Result := ['Larder'];
EHouseObject.REPAIR_STAND: Result := ['Repair', 'stand'];
EHouseObject.SERVANT_BAG: Result := ['Money', 'bag'];
EHouseObject.GLORY: Result := ['Amulet', 'Glory'];
EHouseObject.MYTH_CAPE: Result := ['Mythical', 'cape'];
EHouseObject.OAK_LECTERN: Result := ['Lectern'];
EHouseObject.EAGLE_LECTERN: Result := ['Lectern'];
EHouseObject.DEMON_LECTERN: Result := ['Lectern'];
EHouseObject.TEAK_EAGLE_LECTERN: Result := ['Lectern'];
EHouseObject.TEAK_DEMON_LECTERN: Result := ['Lectern'];
EHouseObject.MAHOGANY_EAGLE_LECTERN: Result := ['Lectern'];
EHouseObject.MAHOGANY_DEMON_LECTERN: Result := ['Lectern'];
EHouseObject.MARBLE_LECTERN: Result := ['Lectern'];
EHouseObject.PRAYER_ALTAR: Result := ['Altar'];
EHouseObject.OAK_LECTERN..EHouseObject.MARBLE_LECTERN: Result := ['Lectern'];
EHouseObject.OAK_ALTAR..EHouseObject.GILDED_ALTAR: Result := ['Altar'];
EHouseObject.NEXUS: Result := ['Portal', 'Nexus'];
EHouseObject.RESTORATION_POOL: Result := ['pool'];
EHouseObject.REVITALISATION_POOL: Result := ['pool'];
Expand Down Expand Up @@ -330,7 +334,25 @@ begin
Result.Colors += CTS2(8794487, 19, 0.14, 1.33);
Result.Colors += CTS2(3556172, 7, 0.10, 0.27);
end;
EHouseObject.PRAYER_ALTAR:

EHouseObject.LARDER:
begin
Result.Colors += CTS2(1795930, 26, 0.12, 1.66); //TODO...
end;

EHouseObject.OAK_LARDER:
begin
Result.Colors += CTS2(1795930, 26, 0.12, 1.66); //TODO...
end;

EHouseObject.TEAK_LARDER:
begin
Result.Colors += CTS2(6124930, 9, 0.06, 0.13);
Result.Colors += CTS2(3495268, 3, 0.11, 0.51);
Result.Colors += CTS2(4484738, 3, 0.11, 0.23);
end;

EHouseObject.OAK_ALTAR..EHouseObject.GILDED_ALTAR:
begin
//TODO
end;
Expand Down Expand Up @@ -550,8 +572,11 @@ begin
end;
end;

var
const
KITCHEN_LARDERS: set of EHouseObject = [EHouseObject.LARDER..EHouseObject.TEAK_LARDER];
STUDY_LECTERNS: set of EHouseObject = [EHouseObject.OAK_LECTERN..EHouseObject.MARBLE_LECTERN];
CHAPEL_BURNERS: set of EHouseObject = [EHouseObject.LEFT_BURNER, EHouseObject.RIGHT_BURNER];
CHAPEL_ALTARS: set of EHouseObject = [EHouseObject.OAK_ALTAR..EHouseObject.GILDED_ALTAR];
SUPERIOR_GARDEN_POOLS: set of EHouseObject = [EHouseObject.RESTORATION_POOL..EHouseObject.ORNATE_POOL];
SUPERIOR_GARDEN_TELEPORTS: set of EHouseObject = [EHouseObject.SPIRIT_TREE..EHouseObject.SPIRITUAL_FAIRY_TREE];
JEWELLERY_BOXES: set of EHouseObject = [EHouseObject.BASIC_JEWELLERY_BOX..EHouseObject.ORNATE_JEWELLERY_BOX];
Expand Down
Loading

0 comments on commit 8ba339a

Please sign in to comment.