diff --git a/package.json b/package.json
index 22984611..dddc9228 100644
--- a/package.json
+++ b/package.json
@@ -3,8 +3,8 @@
"version": "2.0.0",
"private": true,
"scripts": {
- "start": "cross-env BROWSER=none IMAGE_INLINE_SIZE_LIMIT=100000 craco start",
- "build": "cross-env GENERATE_SOURCEMAP=false IMAGE_INLINE_SIZE_LIMIT=100000 craco build",
+ "start": "cross-env SKIP_PREFLIGHT_CHECK=true BROWSER=none IMAGE_INLINE_SIZE_LIMIT=100000 craco start",
+ "build": "cross-env SKIP_PREFLIGHT_CHECK=true GENERATE_SOURCEMAP=false IMAGE_INLINE_SIZE_LIMIT=100000 craco build",
"build:prod": "npx browserslist@latest --update-db && yarn build",
"test": "craco test",
"eject": "react-scripts eject"
@@ -14,7 +14,7 @@
"@fortawesome/fontawesome-svg-core": "^6.1.0",
"@fortawesome/free-solid-svg-icons": "^6.1.0",
"@fortawesome/react-fontawesome": "^0.1.17",
- "@nitrots/nitro-renderer": "^1.1.20",
+ "@nitrots/nitro-renderer": "^1.1.21",
"animate.css": "^4.1.1",
"classnames": "^2.3.1",
"cross-env": "^7.0.3",
diff --git a/src/api/inventory/TradingNotificationMessage.ts b/src/api/inventory/TradingNotificationMessage.ts
index 8ccbed1a..eb0ecfac 100644
--- a/src/api/inventory/TradingNotificationMessage.ts
+++ b/src/api/inventory/TradingNotificationMessage.ts
@@ -1,28 +1,26 @@
import { LocalizeText, NotificationUtilities } from '..';
import { TradingNotificationType } from './TradingNotificationType';
-export const TradingNotificationMessage = (type: number) =>
+export const TradingNotificationMessage = (type: number, otherUsername: string = '') =>
{
switch(type)
{
case TradingNotificationType.ALERT_SCAM:
NotificationUtilities.simpleAlert(LocalizeText('inventory.trading.warning.other_not_offering'), null, null, null, LocalizeText('inventory.trading.notification.title'));
return;
- case TradingNotificationType.ALERT_OTHER_CANCELLED:
- NotificationUtilities.simpleAlert(LocalizeText('inventory.trading.info.closed'), null, null, null, LocalizeText('inventory.trading.notification.title'));
- return;
- case TradingNotificationType.ALERT_ALREADY_OPEN:
- NotificationUtilities.simpleAlert(LocalizeText('inventory.trading.info.already_open'), null, null, null, LocalizeText('inventory.trading.notification.title'));
- return;
- case TradingNotificationType.ALERT_OTHER_DISABLED:
- NotificationUtilities.simpleAlert(LocalizeText('inventory.trading.warning.others_account_disabled'), null, null, null, LocalizeText('inventory.trading.notification.title'));
+ case TradingNotificationType.HOTEL_TRADING_DISABLED:
+ case TradingNotificationType.YOU_NOT_ALLOWED:
+ case TradingNotificationType.THEY_NOT_ALLOWED:
+ case TradingNotificationType.ROOM_DISABLED:
+ case TradingNotificationType.YOU_OPEN:
+ case TradingNotificationType.THEY_OPEN:
+ NotificationUtilities.simpleAlert(LocalizeText(`inventory.trading.openfail.${ type }`, [ 'otherusername' ], [ otherUsername ]), null, null, null, LocalizeText('inventory.trading.openfail.title'));
return;
case TradingNotificationType.ERROR_WHILE_COMMIT:
NotificationUtilities.simpleAlert(`${ LocalizeText('inventory.trading.notification.caption') }, ${ LocalizeText('inventory.trading.notification.commiterror.info') }`, null, null, null, LocalizeText('inventory.trading.notification.title'));
return;
- case TradingNotificationType.YOU_NOT_ALLOWED:
- NotificationUtilities.simpleAlert(LocalizeText('inventory.trading.warning.own_account_disabled'), null, null, null, LocalizeText('inventory.trading.notification.title'));
+ case TradingNotificationType.THEY_CANCELLED:
+ NotificationUtilities.simpleAlert(LocalizeText('inventory.trading.info.closed'), null, null, null, LocalizeText('inventory.trading.notification.title'));
return;
-
}
}
diff --git a/src/api/inventory/TradingNotificationType.ts b/src/api/inventory/TradingNotificationType.ts
index 9bf59a67..4aed4905 100644
--- a/src/api/inventory/TradingNotificationType.ts
+++ b/src/api/inventory/TradingNotificationType.ts
@@ -1,9 +1,12 @@
export class TradingNotificationType
{
public static ALERT_SCAM: number = 0;
- public static ALERT_OTHER_CANCELLED: number = 1;
- public static ALERT_ALREADY_OPEN: number = 2;
- public static ALERT_OTHER_DISABLED: number = 3;
- public static ERROR_WHILE_COMMIT: number = 4;
- public static YOU_NOT_ALLOWED: number = 5;
+ public static HOTEL_TRADING_DISABLED = 1;
+ public static YOU_NOT_ALLOWED: number = 2;
+ public static THEY_NOT_ALLOWED: number = 4;
+ public static ROOM_DISABLED: number = 6;
+ public static YOU_OPEN: number = 7;
+ public static THEY_OPEN: number = 8;
+ public static ERROR_WHILE_COMMIT: number = 9;
+ public static THEY_CANCELLED: number = 10;
}
diff --git a/src/components/inventory/InventoryView.tsx b/src/components/inventory/InventoryView.tsx
index b85736be..c438e7cc 100644
--- a/src/components/inventory/InventoryView.tsx
+++ b/src/components/inventory/InventoryView.tsx
@@ -107,11 +107,11 @@ export const InventoryView: FC<{}> = props =>
return () =>
{
setRoomPreviewer(prevValue =>
- {
- prevValue.dispose();
+ {
+ prevValue.dispose();
- return null;
- });
+ return null;
+ });
}
}, []);
@@ -129,15 +129,15 @@ export const InventoryView: FC<{}> = props =>
<>
{ TABS.map((name, index) =>
- {
- const unseenCount = getCount(UNSEEN_CATEGORIES[index]);
+ {
+ const unseenCount = getCount(UNSEEN_CATEGORIES[index]);
- return (
- setCurrentTab(name) } count={ unseenCount }>
- { LocalizeText(name) }
-
- );
- }) }
+ return (
+ setCurrentTab(name) } count={ unseenCount }>
+ { LocalizeText(name) }
+
+ );
+ }) }
{ (currentTab === TAB_FURNITURE ) &&
diff --git a/src/components/inventory/views/InventoryBadgeView.tsx b/src/components/inventory/views/InventoryBadgeView.tsx
index c74aed37..5b183600 100644
--- a/src/components/inventory/views/InventoryBadgeView.tsx
+++ b/src/components/inventory/views/InventoryBadgeView.tsx
@@ -48,11 +48,11 @@ export const InventoryBadgeView: FC<{}> = props =>
{ badgeCodes && (badgeCodes.length > 0) && badgeCodes.map((badgeCode, index) =>
- {
- if(activeBadgeCodes.indexOf(badgeCode) >= 0) return null;
+ {
+ if(activeBadgeCodes.indexOf(badgeCode) >= 0) return null;
- return
- }) }
+ return
+ }) }
diff --git a/src/components/inventory/views/InventoryFurnitureSearchView.tsx b/src/components/inventory/views/InventoryFurnitureSearchView.tsx
index b36e4b9e..d81d6060 100644
--- a/src/components/inventory/views/InventoryFurnitureSearchView.tsx
+++ b/src/components/inventory/views/InventoryFurnitureSearchView.tsx
@@ -23,14 +23,14 @@ export const InventoryFurnitureSearchView: FC
const comparison = searchValue.toLocaleLowerCase();
filteredGroupItems = groupItems.filter(item =>
+ {
+ if(comparison && comparison.length)
{
- if(comparison && comparison.length)
- {
- if(item.name.toLocaleLowerCase().includes(comparison)) return item;
- }
+ if(item.name.toLocaleLowerCase().includes(comparison)) return item;
+ }
- return null;
- });
+ return null;
+ });
}
setGroupItems(filteredGroupItems);
diff --git a/src/components/inventory/views/InventoryFurnitureView.tsx b/src/components/inventory/views/InventoryFurnitureView.tsx
index faa52af4..8833d2fd 100644
--- a/src/components/inventory/views/InventoryFurnitureView.tsx
+++ b/src/components/inventory/views/InventoryFurnitureView.tsx
@@ -16,8 +16,8 @@ interface InventoryFurnitureViewProps
export const InventoryFurnitureView: FC = props =>
{
const { roomSession = null, roomPreviewer = null } = props;
- const { groupItems = [], selectedItem = null, selectItem = null } = useInventoryFurni();
- const [ filteredGroupItems, setFilteredGroupItems ] = useState(groupItems);
+ const [ filteredGroupItems, setFilteredGroupItems ] = useState([]);
+ const { groupItems = [], selectedItem = null, selectItem = null, activate = null, deactivate = null } = useInventoryFurni();
const { getCount = null, resetCategory = null } = useInventoryUnseenTracker();
useEffect(() =>
@@ -86,6 +86,13 @@ export const InventoryFurnitureView: FC = props =>
}
}, [ groupItems, getCount, resetCategory ]);
+ useEffect(() =>
+ {
+ const id = activate();
+
+ return () => deactivate(id);
+ }, [ activate, deactivate ]);
+
if(!groupItems || !groupItems.length) return ;
const InventoryFurnitureItemView: FC<{ groupItem: GroupItem }> = props =>
diff --git a/src/components/inventory/views/InventoryTradeView.tsx b/src/components/inventory/views/InventoryTradeView.tsx
index 0614436b..a43bfbe8 100644
--- a/src/components/inventory/views/InventoryTradeView.tsx
+++ b/src/components/inventory/views/InventoryTradeView.tsx
@@ -127,13 +127,13 @@ export const InventoryTradeView: FC = props =>
const interval = setInterval(() =>
{
setCountdownTick(prevValue =>
- {
- const newValue = (prevValue - 1);
+ {
+ const newValue = (prevValue - 1);
- if(newValue === 0) clearInterval(interval);
+ if(newValue === 0) clearInterval(interval);
- return newValue;
- });
+ return newValue;
+ });
}, 1000);
return () => clearInterval(interval);
@@ -155,18 +155,18 @@ export const InventoryTradeView: FC = props =>
{ filteredGroupItems && (filteredGroupItems.length > 0) && filteredGroupItems.map((item, index) =>
- {
- const count = item.getUnlockedCount();
+ {
+ const count = item.getUnlockedCount();
- return (
- (count && setGroupItem(item)) }>
- { ((count > 0) && (groupItem === item)) &&
+ return (
+ (count && setGroupItem(item)) }>
+ { ((count > 0) && (groupItem === item)) &&
}
-
- );
- }) }
+
+ );
+ }) }
{ groupItem ? groupItem.name : LocalizeText('catalog_selectproduct') }
@@ -182,20 +182,20 @@ export const InventoryTradeView: FC = props =>
{ Array.from(Array(MAX_ITEMS_TO_TRADE), (e, i) =>
- {
- const item = (ownUser.userItems.getWithIndex(i) || null);
+ {
+ const item = (ownUser.userItems.getWithIndex(i) || null);
- if(!item) return ;
+ if(!item) return ;
- return (
- setOwnGroupItem(item) }>
- { (ownGroupItem === item) &&
+ return (
+ setOwnGroupItem(item) }>
+ { (ownGroupItem === item) &&
}
-
- );
- }) }
+
+ );
+ }) }
{ ownGroupItem ? ownGroupItem.name : LocalizeText('catalog_selectproduct') }
@@ -208,13 +208,13 @@ export const InventoryTradeView: FC = props =>
{ Array.from(Array(MAX_ITEMS_TO_TRADE), (e, i) =>
- {
- const item = (otherUser.userItems.getWithIndex(i) || null);
+ {
+ const item = (otherUser.userItems.getWithIndex(i) || null);
- if(!item) return ;
+ if(!item) return ;
- return setOtherGroupItem(item) } />;
- }) }
+ return setOtherGroupItem(item) } />;
+ }) }
{ otherGroupItem ? otherGroupItem.name : LocalizeText('catalog_selectproduct') }
diff --git a/src/components/user-settings/UserSettingsView.tsx b/src/components/user-settings/UserSettingsView.tsx
index 368657c7..a9c001be 100644
--- a/src/components/user-settings/UserSettingsView.tsx
+++ b/src/components/user-settings/UserSettingsView.tsx
@@ -94,7 +94,7 @@ export const UserSettingsView: FC<{}> = props =>
if(doUpdate) setUserSettings(clone);
DispatchMainEvent(clone)
- }, [userSettings]);
+ }, [ userSettings ]);
const saveRangeSlider = useCallback((type: string) =>
{
@@ -104,14 +104,14 @@ export const UserSettingsView: FC<{}> = props =>
SendMessageComposer(new UserSettingsSoundComposer(Math.round(userSettings.volumeSystem), Math.round(userSettings.volumeFurni), Math.round(userSettings.volumeTrax)));
break;
}
- }, [userSettings]);
+ }, [ userSettings ]);
useEffect(() =>
{
if(!userSettings) return;
DispatchUiEvent(userSettings);
- }, [userSettings]);
+ }, [ userSettings ]);
if(!isVisible) return null;
diff --git a/src/hooks/inventory/useInventoryBadges.ts b/src/hooks/inventory/useInventoryBadges.ts
index 373a520a..432ab777 100644
--- a/src/hooks/inventory/useInventoryBadges.ts
+++ b/src/hooks/inventory/useInventoryBadges.ts
@@ -21,30 +21,30 @@ const useInventoryBadgesState = () =>
const toggleBadge = (badgeCode: string) =>
{
setActiveBadgeCodes(prevValue =>
+ {
+ const newValue = [ ...prevValue ];
+
+ const index = newValue.indexOf(badgeCode);
+
+ if(index === -1)
{
- const newValue = [ ...prevValue ];
+ if(!canWearBadges()) return prevValue;
- const index = newValue.indexOf(badgeCode);
+ newValue.push(badgeCode);
+ }
+ else
+ {
+ newValue.splice(index, 1);
+ }
- if(index === -1)
- {
- if(!canWearBadges()) return prevValue;
+ const composer = new SetActivatedBadgesComposer();
- newValue.push(badgeCode);
- }
- else
- {
- newValue.splice(index, 1);
- }
+ for(let i = 0; i < maxBadgeCount; i++) composer.addActivatedBadge(newValue[i] || null);
- const composer = new SetActivatedBadgesComposer();
+ SendMessageComposer(composer);
- for(let i = 0; i < maxBadgeCount; i++) composer.addActivatedBadge(newValue[i] || null);
-
- SendMessageComposer(composer);
-
- return newValue;
- });
+ return newValue;
+ });
}
const selectBadge = (badgeCode: string) =>
@@ -89,22 +89,22 @@ const useInventoryBadgesState = () =>
BatchUpdates(() =>
{
setBadgeCodes(prevValue =>
- {
- const newValue = [ ...prevValue ];
+ {
+ const newValue = [ ...prevValue ];
- newValue.push(parser.badgeCode);
+ newValue.push(parser.badgeCode);
- return newValue;
- });
+ return newValue;
+ });
setBadgeIds(prevValue =>
- {
- const newValue = [ ...prevValue ];
+ {
+ const newValue = [ ...prevValue ];
- newValue.push(parser.badgeId);
+ newValue.push(parser.badgeId);
- return newValue;
- })
+ return newValue;
+ })
});
}, []);
@@ -115,15 +115,15 @@ const useInventoryBadgesState = () =>
if(!badgeCodes || !badgeCodes.length) return;
setSelectedBadgeCode(prevValue =>
- {
- let newValue = prevValue;
+ {
+ let newValue = prevValue;
- if(newValue && (badgeCodes.indexOf(newValue) === -1)) newValue = null;
+ if(newValue && (badgeCodes.indexOf(newValue) === -1)) newValue = null;
- if(!newValue) newValue = badgeCodes[0];
+ if(!newValue) newValue = badgeCodes[0];
- return newValue;
- });
+ return newValue;
+ });
}, [ badgeCodes ]);
useEffect(() =>
diff --git a/src/hooks/inventory/useInventoryBots.ts b/src/hooks/inventory/useInventoryBots.ts
index 31e82b32..2f13947a 100644
--- a/src/hooks/inventory/useInventoryBots.ts
+++ b/src/hooks/inventory/useInventoryBots.ts
@@ -21,55 +21,55 @@ const useInventoryBotsState = () =>
const parser = event.getParser();
setBotItems(prevValue =>
+ {
+ const newValue = [ ...prevValue ];
+ const existingIds = newValue.map(item => item.botData.id);
+ const addedDatas: BotData[] = [];
+
+ for(const botData of parser.items.values()) ((existingIds.indexOf(botData.id) === -1) && addedDatas.push(botData));
+
+ for(const existingId of existingIds)
{
- const newValue = [ ...prevValue ];
- const existingIds = newValue.map(item => item.botData.id);
- const addedDatas: BotData[] = [];
+ let remove = true;
- for(const botData of parser.items.values()) ((existingIds.indexOf(botData.id) === -1) && addedDatas.push(botData));
-
- for(const existingId of existingIds)
+ for(const botData of parser.items.values())
{
- let remove = true;
-
- for(const botData of parser.items.values())
+ if(botData.id === existingId)
{
- if(botData.id === existingId)
- {
- remove = false;
+ remove = false;
- break;
- }
+ break;
}
-
- if(!remove) continue;
-
- const index = newValue.findIndex(item => (item.botData.id === existingId));
- const botItem = newValue[index];
-
- if((index === -1) || !botItem) continue;
-
- if(getPlacingItemId() === botItem.botData.id)
- {
- cancelRoomObjectPlacement();
-
- CreateLinkEvent('inventory/open');
- }
-
- newValue.splice(index, 1);
}
- for(const botData of addedDatas)
- {
- const botItem = { botData } as IBotItem;
- const unseen = isUnseen(UnseenItemCategory.BOT, botData.id);
+ if(!remove) continue;
- if(unseen) newValue.unshift(botItem);
- newValue.push(botItem);
+ const index = newValue.findIndex(item => (item.botData.id === existingId));
+ const botItem = newValue[index];
+
+ if((index === -1) || !botItem) continue;
+
+ if(getPlacingItemId() === botItem.botData.id)
+ {
+ cancelRoomObjectPlacement();
+
+ CreateLinkEvent('inventory/open');
}
- return newValue;
- });
+ newValue.splice(index, 1);
+ }
+
+ for(const botData of addedDatas)
+ {
+ const botItem = { botData } as IBotItem;
+ const unseen = isUnseen(UnseenItemCategory.BOT, botData.id);
+
+ if(unseen) newValue.unshift(botItem);
+ newValue.push(botItem);
+ }
+
+ return newValue;
+ });
}, [ isUnseen ]);
UseMessageEventHook(BotInventoryMessageEvent, onBotInventoryMessageEvent);
@@ -79,19 +79,19 @@ const useInventoryBotsState = () =>
const parser = event.getParser();
setBotItems(prevValue =>
- {
- const newValue = [ ...prevValue ];
+ {
+ const newValue = [ ...prevValue ];
- const index = newValue.findIndex(item => (item.botData.id === parser.item.id));
+ const index = newValue.findIndex(item => (item.botData.id === parser.item.id));
- if(index >= 0) return prevValue;
+ if(index >= 0) return prevValue;
- const botItem = { botData: parser.item } as IBotItem;
+ const botItem = { botData: parser.item } as IBotItem;
- newValue.push(botItem);
+ newValue.push(botItem);
- return newValue;
- });
+ return newValue;
+ });
}, []);
UseMessageEventHook(BotAddedToInventoryEvent, onBotAddedToInventoryEvent);
@@ -101,24 +101,24 @@ const useInventoryBotsState = () =>
const parser = event.getParser();
setBotItems(prevValue =>
+ {
+ const newValue = [ ...prevValue ];
+
+ const index = newValue.findIndex(item => (item.botData.id === parser.itemId));
+
+ if(index === -1) return prevValue;
+
+ newValue.splice(index, 1);
+
+ if(getPlacingItemId() === parser.itemId)
{
- const newValue = [ ...prevValue ];
+ cancelRoomObjectPlacement();
- const index = newValue.findIndex(item => (item.botData.id === parser.itemId));
+ CreateLinkEvent('inventory/show');
+ }
- if(index === -1) return prevValue;
-
- newValue.splice(index, 1);
-
- if(getPlacingItemId() === parser.itemId)
- {
- cancelRoomObjectPlacement();
-
- CreateLinkEvent('inventory/show');
- }
-
- return newValue;
- });
+ return newValue;
+ });
}, []);
UseMessageEventHook(BotRemovedFromInventoryEvent, onBotRemovedFromInventoryEvent);
@@ -128,15 +128,15 @@ const useInventoryBotsState = () =>
if(!botItems || !botItems.length) return;
setSelectedBot(prevValue =>
- {
- let newValue = prevValue;
+ {
+ let newValue = prevValue;
- if(newValue && (botItems.indexOf(newValue) === -1)) newValue = null;
+ if(newValue && (botItems.indexOf(newValue) === -1)) newValue = null;
- if(!newValue) newValue = botItems[0];
+ if(!newValue) newValue = botItems[0];
- return newValue;
- });
+ return newValue;
+ });
}, [ botItems ]);
useEffect(() =>
diff --git a/src/hooks/inventory/useInventoryFurni.ts b/src/hooks/inventory/useInventoryFurni.ts
index 427c5de5..471803aa 100644
--- a/src/hooks/inventory/useInventoryFurni.ts
+++ b/src/hooks/inventory/useInventoryFurni.ts
@@ -29,63 +29,63 @@ const useInventoryFurniState = () =>
const parser = event.getParser();
setGroupItems(prevValue =>
+ {
+ const newValue = [ ...prevValue ];
+
+ for(const item of parser.items)
{
- const newValue = [ ...prevValue ];
+ let i = 0;
+ let groupItem: GroupItem = null;
- for(const item of parser.items)
+ while(i < newValue.length)
{
- let i = 0;
- let groupItem: GroupItem = null;
+ const group = newValue[i];
- while(i < newValue.length)
+ let j = 0;
+
+ while(j < group.items.length)
{
- const group = newValue[i];
+ const furniture = group.items[j];
- let j = 0;
-
- while(j < group.items.length)
+ if(furniture.id === item.itemId)
{
- const furniture = group.items[j];
+ furniture.update(item);
- if(furniture.id === item.itemId)
- {
- furniture.update(item);
+ const newFurniture = [ ...group.items ];
- const newFurniture = [ ...group.items ];
+ newFurniture[j] = furniture;
- newFurniture[j] = furniture;
+ group.items = newFurniture;
- group.items = newFurniture;
+ groupItem = group;
- groupItem = group;
-
- break;
- }
-
- j++
+ break;
}
- if(groupItem) break;
-
- i++;
+ j++
}
- if(groupItem)
- {
- groupItem.hasUnseenItems = true;
+ if(groupItem) break;
- newValue[i] = CloneObject(groupItem);
- }
- else
- {
- const furniture = new FurnitureItem(item);
-
- addFurnitureItem(newValue, furniture, isUnseen(UnseenItemCategory.FURNI, item.itemId));
- }
+ i++;
}
- return newValue;
- });
+ if(groupItem)
+ {
+ groupItem.hasUnseenItems = true;
+
+ newValue[i] = CloneObject(groupItem);
+ }
+ else
+ {
+ const furniture = new FurnitureItem(item);
+
+ addFurnitureItem(newValue, furniture, isUnseen(UnseenItemCategory.FURNI, item.itemId));
+ }
+ }
+
+ return newValue;
+ });
}, [ isUnseen ]);
UseMessageEventHook(FurnitureListAddOrUpdateEvent, onFurnitureListAddOrUpdateEvent);
@@ -101,65 +101,65 @@ const useInventoryFurniState = () =>
if(!fragment) return;
setGroupItems(prevValue =>
+ {
+ const newValue = [ ...prevValue ];
+ const existingIds = getAllItemIds(newValue);
+
+ for(const existingId of existingIds)
{
- const newValue = [ ...prevValue ];
- const existingIds = getAllItemIds(newValue);
+ if(fragment.get(existingId)) continue;
- for(const existingId of existingIds)
+ let index = 0;
+
+ while(index < newValue.length)
{
- if(fragment.get(existingId)) continue;
+ const group = newValue[index];
+ const item = group.remove(existingId);
- let index = 0;
-
- while(index < newValue.length)
+ if(!item)
{
- const group = newValue[index];
- const item = group.remove(existingId);
+ index++;
- if(!item)
- {
- index++;
-
- continue;
- }
-
- if(getPlacingItemId() === item.ref)
- {
- cancelRoomObjectPlacement();
-
- if(!attemptItemPlacement(group))
- {
- CreateLinkEvent('inventory/show');
- }
- }
-
- if(group.getTotalCount() <= 0)
- {
- newValue.splice(index, 1);
-
- group.dispose();
- }
-
- break;
+ continue;
}
+
+ if(getPlacingItemId() === item.ref)
+ {
+ cancelRoomObjectPlacement();
+
+ if(!attemptItemPlacement(group))
+ {
+ CreateLinkEvent('inventory/show');
+ }
+ }
+
+ if(group.getTotalCount() <= 0)
+ {
+ newValue.splice(index, 1);
+
+ group.dispose();
+ }
+
+ break;
}
+ }
- for(const itemId of fragment.keys())
- {
- if(existingIds.indexOf(itemId) >= 0) continue;
+ for(const itemId of fragment.keys())
+ {
+ if(existingIds.indexOf(itemId) >= 0) continue;
- const parser = fragment.get(itemId);
+ const parser = fragment.get(itemId);
- if(!parser) continue;
+ if(!parser) continue;
- const item = new FurnitureItem(parser);
+ const item = new FurnitureItem(parser);
- addFurnitureItem(newValue, item, isUnseen(UnseenItemCategory.FURNI, itemId));
+ addFurnitureItem(newValue, item, isUnseen(UnseenItemCategory.FURNI, itemId));
- }
+ }
- return newValue;
- });
+ return newValue;
+ });
furniMsgFragments = null;
}, [ isUnseen ]);
@@ -178,42 +178,42 @@ const useInventoryFurniState = () =>
const parser = event.getParser();
setGroupItems(prevValue =>
+ {
+ const newValue = [ ...prevValue ];
+
+ let index = 0;
+
+ while(index < newValue.length)
{
- const newValue = [ ...prevValue ];
+ const group = newValue[index];
+ const item = group.remove(parser.itemId);
- let index = 0;
-
- while(index < newValue.length)
+ if(!item)
{
- const group = newValue[index];
- const item = group.remove(parser.itemId);
+ index++;
- if(!item)
- {
- index++;
-
- continue;
- }
+ continue;
+ }
- if(getPlacingItemId() === item.ref)
- {
- cancelRoomObjectPlacement();
+ if(getPlacingItemId() === item.ref)
+ {
+ cancelRoomObjectPlacement();
- if(!attemptItemPlacement(group)) CreateLinkEvent('inventory/show');
- }
-
- if(group.getTotalCount() <= 0)
- {
- newValue.splice(index, 1);
-
- group.dispose();
- }
-
- break;
+ if(!attemptItemPlacement(group)) CreateLinkEvent('inventory/show');
}
- return newValue;
- });
+ if(group.getTotalCount() <= 0)
+ {
+ newValue.splice(index, 1);
+
+ group.dispose();
+ }
+
+ break;
+ }
+
+ return newValue;
+ });
}, []);
UseMessageEventHook(FurnitureListRemovedEvent, onFurnitureListRemovedEvent);
@@ -230,15 +230,15 @@ const useInventoryFurniState = () =>
if(!groupItems || !groupItems.length) return;
setSelectedItem(prevValue =>
- {
- let newValue = prevValue;
+ {
+ let newValue = prevValue;
- if(newValue && (groupItems.indexOf(newValue) === -1)) newValue = null;
+ if(newValue && (groupItems.indexOf(newValue) === -1)) newValue = null;
- if(!newValue) newValue = groupItems[0];
+ if(!newValue) newValue = groupItems[0];
- return newValue;
- });
+ return newValue;
+ });
}, [ groupItems ]);
useEffect(() =>
@@ -258,17 +258,10 @@ export const useInventoryFurni = () =>
const { setIsVisible, ...rest } = useBetween(useInventoryFurniState);
const { isVisible = false, activate = null, deactivate = null } = useSharedVisibility();
- useEffect(() =>
- {
- const id = activate();
-
- return () => deactivate(id);
- }, [ activate, deactivate ]);
-
useEffect(() =>
{
setIsVisible(isVisible);
}, [ isVisible, setIsVisible ]);
- return { ...rest };
+ return { activate, deactivate, ...rest };
}
diff --git a/src/hooks/inventory/useInventoryPets.ts b/src/hooks/inventory/useInventoryPets.ts
index b60b65bf..bbd3506a 100644
--- a/src/hooks/inventory/useInventoryPets.ts
+++ b/src/hooks/inventory/useInventoryPets.ts
@@ -31,13 +31,13 @@ const useInventoryPetsState = () =>
if(!fragment) return;
setPetItems(prevValue =>
- {
- const newValue = [ ...prevValue ];
+ {
+ const newValue = [ ...prevValue ];
- processPetFragment(newValue, fragment, isUnseen);
+ processPetFragment(newValue, fragment, isUnseen);
- return newValue;
- });
+ return newValue;
+ });
petMsgFragments = null;
}, [ isUnseen ]);
@@ -49,13 +49,13 @@ const useInventoryPetsState = () =>
const parser = event.getParser();
setPetItems(prevValue =>
- {
- const newValue = [ ...prevValue ];
+ {
+ const newValue = [ ...prevValue ];
- addSinglePetItem(parser.pet, newValue, true);
+ addSinglePetItem(parser.pet, newValue, true);
- return newValue;
- });
+ return newValue;
+ });
}, []);
UseMessageEventHook(PetAddedToInventoryEvent, onPetAddedToInventoryEvent);
@@ -65,13 +65,13 @@ const useInventoryPetsState = () =>
const parser = event.getParser();
setPetItems(prevValue =>
- {
- const newValue = [ ...prevValue ];
+ {
+ const newValue = [ ...prevValue ];
- removePetItemById(parser.petId, newValue);
+ removePetItemById(parser.petId, newValue);
- return newValue;
- });
+ return newValue;
+ });
}, []);
UseMessageEventHook(PetRemovedFromInventory, onPetRemovedFromInventory);
@@ -81,15 +81,15 @@ const useInventoryPetsState = () =>
if(!petItems || !petItems.length) return;
setSelectedPet(prevValue =>
- {
- let newValue = prevValue;
+ {
+ let newValue = prevValue;
- if(newValue && (petItems.indexOf(newValue) === -1)) newValue = null;
+ if(newValue && (petItems.indexOf(newValue) === -1)) newValue = null;
- if(!newValue) newValue = petItems[0];
+ if(!newValue) newValue = petItems[0];
- return newValue;
- });
+ return newValue;
+ });
}, [ petItems ]);
useEffect(() =>
diff --git a/src/hooks/inventory/useInventoryTrade.ts b/src/hooks/inventory/useInventoryTrade.ts
index e2b6c158..fa1541c2 100644
--- a/src/hooks/inventory/useInventoryTrade.ts
+++ b/src/hooks/inventory/useInventoryTrade.ts
@@ -1,5 +1,5 @@
-import { AdvancedMap, TradingAcceptComposer, TradingAcceptEvent, TradingCancelComposer, TradingCloseComposer, TradingCloseEvent, TradingCloseParser, TradingCompletedEvent, TradingConfirmationComposer, TradingConfirmationEvent, TradingListItemEvent, TradingListItemRemoveComposer, TradingNotOpenEvent, TradingOpenComposer, TradingOpenEvent, TradingOpenFailedEvent, TradingOpenFailedParser, TradingOtherNotAllowedEvent, TradingUnacceptComposer, TradingYouAreNotAllowedEvent } from '@nitrots/nitro-renderer';
-import { useCallback, useState } from 'react';
+import { AdvancedMap, TradingAcceptComposer, TradingAcceptEvent, TradingCancelComposer, TradingCloseComposer, TradingCloseEvent, TradingCloseParser, TradingCompletedEvent, TradingConfirmationComposer, TradingConfirmationEvent, TradingListItemEvent, TradingListItemRemoveComposer, TradingNotOpenEvent, TradingOpenComposer, TradingOpenEvent, TradingOpenFailedEvent, TradingOtherNotAllowedEvent, TradingUnacceptComposer, TradingYouAreNotAllowedEvent } from '@nitrots/nitro-renderer';
+import { useCallback, useEffect, useState } from 'react';
import { useBetween } from 'use-between';
import { useInventoryFurni } from '.';
import { BatchUpdates, UseMessageEventHook } from '..';
@@ -13,7 +13,7 @@ const useInventoryTradeState = () =>
const [ ownUser, setOwnUser ] = useState(null);
const [ otherUser, setOtherUser ] = useState(null);
const [ tradeState, setTradeState ] = useState(TradeState.TRADING_STATE_READY);
- const { groupItems = [], setGroupItems = null } = useInventoryFurni();
+ const { groupItems = [], setGroupItems = null, activate = null, deactivate = null } = useInventoryFurni();
const isTrading = (tradeState >= TradeState.TRADING_STATE_RUNNING);
const progressTrade = () =>
@@ -90,25 +90,25 @@ const useInventoryTradeState = () =>
if(ownUser.userId === parser.userID)
{
setOwnUser(prevValue =>
- {
- const newValue = CloneObject(prevValue);
+ {
+ const newValue = CloneObject(prevValue);
- newValue.accepts = parser.userAccepts;
+ newValue.accepts = parser.userAccepts;
- return newValue;
- });
+ return newValue;
+ });
}
else if(otherUser.userId === parser.userID)
{
setOtherUser(prevValue =>
- {
- const newValue = CloneObject(prevValue);
+ {
+ const newValue = CloneObject(prevValue);
- newValue.accepts = parser.userAccepts;
+ newValue.accepts = parser.userAccepts;
- return newValue;
- });
+ return newValue;
+ });
}
}, [ ownUser, otherUser ]);
@@ -126,7 +126,7 @@ const useInventoryTradeState = () =>
{
if(ownUser && (parser.userID !== ownUser.userId))
{
- TradingNotificationMessage(TradingNotificationType.ALERT_OTHER_CANCELLED);
+ TradingNotificationMessage(TradingNotificationType.THEY_CANCELLED);
}
}
@@ -170,69 +170,69 @@ const useInventoryTradeState = () =>
const secondUserItems = parseTradeItems(parser.secondUserItemArray);
setOwnUser(prevValue =>
+ {
+ const newValue = CloneObject(prevValue);
+
+ if(newValue.userId === parser.firstUserID)
{
- const newValue = CloneObject(prevValue);
+ newValue.creditsCount = parser.firstUserNumCredits;
+ newValue.itemCount = parser.firstUserNumItems;
+ newValue.userItems = firstUserItems;
+ }
+ else
+ {
+ newValue.creditsCount = parser.secondUserNumCredits;
+ newValue.itemCount = parser.secondUserNumItems;
+ newValue.userItems = secondUserItems;
+ }
- if(newValue.userId === parser.firstUserID)
+ const tradeIds: number[] = [];
+
+ for(const groupItem of newValue.userItems.getValues())
+ {
+ let i = 0;
+
+ while(i < groupItem.getTotalCount())
{
- newValue.creditsCount = parser.firstUserNumCredits;
- newValue.itemCount = parser.firstUserNumItems;
- newValue.userItems = firstUserItems;
- }
- else
- {
- newValue.creditsCount = parser.secondUserNumCredits;
- newValue.itemCount = parser.secondUserNumItems;
- newValue.userItems = secondUserItems;
+ const item = groupItem.getItemByIndex(i);
+
+ if(item) tradeIds.push(item.ref);
+
+ i++;
}
+ }
- const tradeIds: number[] = [];
+ setGroupItems(prevValue =>
+ {
+ const newValue = [ ...prevValue ];
- for(const groupItem of newValue.userItems.getValues())
- {
- let i = 0;
-
- while(i < groupItem.getTotalCount())
- {
- const item = groupItem.getItemByIndex(i);
-
- if(item) tradeIds.push(item.ref);
-
- i++;
- }
- }
-
- setGroupItems(prevValue =>
- {
- const newValue = [ ...prevValue ];
-
- for(const groupItem of newValue) groupItem.lockItemIds(tradeIds);
-
- return newValue;
- });
+ for(const groupItem of newValue) groupItem.lockItemIds(tradeIds);
return newValue;
});
+ return newValue;
+ });
+
setOtherUser(prevValue =>
+ {
+ const newValue = CloneObject(prevValue);
+
+ if(newValue.userId === parser.firstUserID)
{
- const newValue = CloneObject(prevValue);
+ newValue.creditsCount = parser.firstUserNumCredits;
+ newValue.itemCount = parser.firstUserNumItems;
+ newValue.userItems = firstUserItems;
+ }
+ else
+ {
+ newValue.creditsCount = parser.secondUserNumCredits;
+ newValue.itemCount = parser.secondUserNumItems;
+ newValue.userItems = secondUserItems;
+ }
- if(newValue.userId === parser.firstUserID)
- {
- newValue.creditsCount = parser.firstUserNumCredits;
- newValue.itemCount = parser.firstUserNumItems;
- newValue.userItems = firstUserItems;
- }
- else
- {
- newValue.creditsCount = parser.secondUserNumCredits;
- newValue.itemCount = parser.secondUserNumItems;
- newValue.userItems = secondUserItems;
- }
-
- return newValue;
- });
+ return newValue;
+ });
}, [ setGroupItems ]);
UseMessageEventHook(TradingListItemEvent, onTradingListItemEvent);
@@ -294,9 +294,7 @@ const useInventoryTradeState = () =>
{
const parser = event.getParser();
- if((parser.reason !== TradingOpenFailedParser.REASON_YOU_ARE_ALREADY_TRADING && (parser.reason !== TradingOpenFailedParser.REASON_OTHER_USER_ALREADY_TRADING))) return;
-
- TradingNotificationMessage(TradingNotificationType.ALERT_ALREADY_OPEN);
+ TradingNotificationMessage(parser.reason, parser.otherUserName);
}, []);
UseMessageEventHook(TradingOpenFailedEvent, onTradingOpenFailedEvent);
@@ -305,7 +303,7 @@ const useInventoryTradeState = () =>
{
const parser = event.getParser();
- TradingNotificationMessage(TradingNotificationType.ALERT_OTHER_DISABLED);
+ TradingNotificationMessage(TradingNotificationType.THEY_NOT_ALLOWED);
}, []);
UseMessageEventHook(TradingOtherNotAllowedEvent, onTradingOtherNotAllowedEvent);
@@ -319,6 +317,15 @@ const useInventoryTradeState = () =>
UseMessageEventHook(TradingYouAreNotAllowedEvent, onTradingYouAreNotAllowedEvent);
+ useEffect(() =>
+ {
+ if(tradeState === TradeState.TRADING_STATE_READY) return;
+
+ const id = activate();
+
+ return () => deactivate(id);
+ }, [ tradeState, activate, deactivate ]);
+
return { ownUser, otherUser, tradeState, setTradeState, isTrading, groupItems, progressTrade, removeItem, stopTrading };
}
diff --git a/src/hooks/inventory/useInventoryUnseenTracker.ts b/src/hooks/inventory/useInventoryUnseenTracker.ts
index 5f011ab5..86ac95eb 100644
--- a/src/hooks/inventory/useInventoryUnseenTracker.ts
+++ b/src/hooks/inventory/useInventoryUnseenTracker.ts
@@ -27,13 +27,13 @@ const useInventoryUnseenTrackerState = () =>
if(!getCount(category)) return false;
setUnseenItems(prevValue =>
- {
- const newValue = new Map(prevValue);
+ {
+ const newValue = new Map(prevValue);
- newValue.delete(category);
+ newValue.delete(category);
- return newValue;
- });
+ return newValue;
+ });
sendResetCategoryMessage(category);
@@ -45,13 +45,13 @@ const useInventoryUnseenTrackerState = () =>
if(getCount(category)) return false;
setUnseenItems(prevValue =>
- {
- const newValue = new Map(prevValue);
+ {
+ const newValue = new Map(prevValue);
- newValue.delete(category);
+ newValue.delete(category);
- return newValue;
- });
+ return newValue;
+ });
sendResetCategoryMessage(category);
@@ -63,14 +63,14 @@ const useInventoryUnseenTrackerState = () =>
if(!getCount(category)) return false;
setUnseenItems(prevValue =>
- {
- const newValue = new Map(prevValue);
- const existing = newValue.get(category);
+ {
+ const newValue = new Map(prevValue);
+ const existing = newValue.get(category);
- if(existing) for(const itemId of itemIds) existing.splice(existing.indexOf(itemId), 1);
+ if(existing) for(const itemId of itemIds) existing.splice(existing.indexOf(itemId), 1);
- return newValue;
- });
+ return newValue;
+ });
sendResetItemsMessage(category, itemIds);
@@ -91,18 +91,18 @@ const useInventoryUnseenTrackerState = () =>
if(!unseenItems.has(category)) return false;
setUnseenItems(prevValue =>
+ {
+ const newValue = new Map(prevValue);
+ const items = newValue.get(category);
+ const index = items.indexOf(itemId);
+
+ if(index >= 0)
{
- const newValue = new Map(prevValue);
- const items = newValue.get(category);
- const index = items.indexOf(itemId);
+ items.splice(index, 1);
+ }
- if(index >= 0)
- {
- items.splice(index, 1);
- }
-
- return newValue;
- });
+ return newValue;
+ });
}
const onUnseenItemsEvent = useCallback((event: UnseenItemsEvent) =>
@@ -110,27 +110,27 @@ const useInventoryUnseenTrackerState = () =>
const parser = event.getParser();
setUnseenItems(prevValue =>
+ {
+ const newValue = new Map(prevValue);
+
+ for(const category of parser.categories)
{
- const newValue = new Map(prevValue);
+ let existing = newValue.get(category);
- for(const category of parser.categories)
+ if(!existing)
{
- let existing = newValue.get(category);
+ existing = [];
- if(!existing)
- {
- existing = [];
-
- newValue.set(category, existing);
- }
-
- const itemIds = parser.getItemsByCategory(category);
-
- for(const itemId of itemIds) ((existing.indexOf(itemId) === -1) && existing.push(itemId));
+ newValue.set(category, existing);
}
- return newValue;
- });
+ const itemIds = parser.getItemsByCategory(category);
+
+ for(const itemId of itemIds) ((existing.indexOf(itemId) === -1) && existing.push(itemId));
+ }
+
+ return newValue;
+ });
}, []);
UseMessageEventHook(UnseenItemsEvent, onUnseenItemsEvent);
diff --git a/src/hooks/useSharedVisibility.ts b/src/hooks/useSharedVisibility.ts
index ce5fa232..b55855b5 100644
--- a/src/hooks/useSharedVisibility.ts
+++ b/src/hooks/useSharedVisibility.ts
@@ -11,15 +11,15 @@ export const useSharedVisibility = () =>
let id = -1;
setActiveIds(prevValue =>
- {
- const newValue = [ ...prevValue ];
+ {
+ const newValue = [ ...prevValue ];
- id = newValue.length ? (newValue[(newValue.length - 1)] + 1) : 0;
+ id = newValue.length ? (newValue[(newValue.length - 1)] + 1) : 0;
- newValue.push(id);
+ newValue.push(id);
- return newValue;
- });
+ return newValue;
+ });
return id;
}, []);
@@ -27,17 +27,17 @@ export const useSharedVisibility = () =>
const deactivate = useCallback((id: number) =>
{
setActiveIds(prevValue =>
- {
- const newValue = [ ...prevValue ];
+ {
+ const newValue = [ ...prevValue ];
- const index = newValue.indexOf(id);
+ const index = newValue.indexOf(id);
- if(index === -1) return prevValue;
+ if(index === -1) return prevValue;
- newValue.splice(index, 1);
+ newValue.splice(index, 1);
- return newValue;
- });
+ return newValue;
+ });
}, []);
return { isVisible, activate, deactivate };
diff --git a/yarn.lock b/yarn.lock
index ff392b0f..5a9ba613 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1426,10 +1426,10 @@
"@jridgewell/resolve-uri" "^3.0.3"
"@jridgewell/sourcemap-codec" "^1.4.10"
-"@nitrots/nitro-renderer@^1.1.20":
- version "1.1.20"
- resolved "https://registry.yarnpkg.com/@nitrots/nitro-renderer/-/nitro-renderer-1.1.20.tgz#13fd468028542f777d2c1c7902f2247769ffd98d"
- integrity sha512-DVwM4M0Iofsgd94dVPoNmzPbt7YzVG5liupULIe+WHo2vhR8fEyq3E+cdQleXtr/MBODGXTHBrU0yL67YDpIRQ==
+"@nitrots/nitro-renderer@^1.1.21":
+ version "1.1.21"
+ resolved "https://registry.yarnpkg.com/@nitrots/nitro-renderer/-/nitro-renderer-1.1.21.tgz#8d527d63510fb4c3003e7d48347cdd50b67bb5b1"
+ integrity sha512-futoNgDy+wD1il7gEnKly/VlRdESJZrPkG9m+jDy3bswdpRZ0RAph1XYNpNzkSchpxXib2yuKMME6ePPct/l1A==
dependencies:
"@pixi/canvas-renderer" "^6.3.0"
"@pixi/extract" "^6.3.0"