mirror of
https://github.com/UOX3DevTeam/UOX3
synced 2026-08-13 12:27:04 -04:00
Added JS command to reload dictionaries 'reloaddictionaries Fixed a server crash related to casting of spells Fixed some issues with Line-of-Sight checks related to items under/above ground, LoS checks between different floors of buildings, etc. Updated handling of skill-training keywords to be based on language-independent keyword IDs rather than trying to match player-input text to specific skill-names Updated animal-trainer/stablemasterscript (js/npc/ai/stablemaster.js) with several changes: Fixed an issue where the same pet would be stabled in all available slots if payment was taken from player's bank account instead of their backpack Fixed an issue where stablemaster would not pause walking for a while when a player interacts with them Converted all system messages and text messages in stablemaster script to dictionary entries Added new NPC AI type to source - AI_STABLEMASTER (9) - and assigned this to animal trainers. This is used to identify this type of NPCs for the purpose of displaying relevant context menus Reworked banker AI script (js/npc/ai/banker.js) to use triggerwords from client instead of hard-defined strings, to work better with multiple languages (and work with all relevant triggerwords) Fixed a bug with banker AI script (js/npc/ai/banker.js) that prevented players from using the "withdraw" command Re-added NPC AI 8 to banker NPCs (dfndata/npc/male_vendors.dfn and female_vendors.dfn) so code can check for presence of this AI when handling context menus Removed remaining hard-coded banking functionality - all handled by script anyway Added new context menu option for NPC bankers - Open Bankbox Updated code handling of context menus to only show context menus when relevant: Open Paperdoll - Shows for all characters with a paperdoll Open Backpack - Shows for player's character, pack animals and hirelings Open Bankbox - Shows for banker NPCs (if within 8 tiles) Buy/Sell - Shows for vendor NPCs (if within 8 tiles, and if they have anything for sale/are buying anything) Added new context menu entries for pets, which can be used if player is within 12 tiles of pet: Command: Kill Command: Stop Command: Follow Command: Stay Command: Guard Add Friend Remove Friend Transfer Release Added new context menu entries for stablemasters/animal trainers: Claim All Pets Stable Pet Added new context menu entries for Escort Quest NPCs Ask Destination (if within 3 tiles) Accept Escort (if within 3 tiles) Abandon Escort Added new context menus for NPCs that can teach skills to players (limited to max 10 per NPC) Train [skillName] Added new AI script for NPC hirelings (3204=js/npc/ai/hireling.js), who can be hired to follow the player around for a limited amount of time, and function the same way as pets. In addition to the regular pet commands, these speech commands are supported: hire // The hireling will respond with the cost to hire them dismiss // Replaces the "release" command for pets; will dismiss the hireling patrol // The hireling will patrol between it's current location and a second targeted location nearby move // The hireling will try to shuffle out of the way fetch // The hireling will try to fetch a targeted item drop // The hireling will drop to the ground all loot they're currently carrying report // The hireling will report on the remaining time they're hired for Added new NPC DFN tag used by code to detect hireling NPCs for the purpose of displaying context menus: HIRELING // No additional value/data needed for tag Added new context menu entries for Hireling NPCs, in addition to the ones for regular pets: Hire // Can be used within 3 steps of the hireling, who will respond with cost to hire them Dismiss // Replaces the "release" command for pets, will dismiss the hireling Added HIRELING tag and SCRIPT=3204 to and updated stats of various NPCs that will be hireable: m_fighter, f_fighter, m_beggar, f_beggar, m_peasant, f_peasant, m_sailor, f_sailor, m_pirate, f_pirate Added new hireling NPC: m_paladin, f_paladin Added new UOX ini setting to enable/disable context menus CONTEXTMENUS=1/0 (defaults to 1) Added new Item JS Method to check if an item's ID is on a specified food list .IsOnFoodList( foodList ) // Returns true/false if item's ID is on specified foodList Added new OMNIVORE food list and assigned it to [basehuman] DFN section Added new Character JS Properties .isGuarded // Gets/Sets whether character is guarded by a pet/hireling .guarding // Gets/Sets the object (if any) being guarded by a pet/hireling Fixed multiple issues with health bars, flagging and character highlighting Added some crash protection for invalid data used with CUSTOMINTTAG and CUSTOMSTRINGTAG DFN tags for Items, NPCs and Multis Fixed an issue which prevented hard-coded checks from running when using items Added new global js object (Timer) to make the use of character timers in JS more robust, with properties matching timer names from enum in source. Properties: .TIMEOUT // Time until next attack can be done in combat .INVIS // Time until invisible character becomes visible .HUNGER // Time until character grows more hungry .THIRST // Time until character grows more thirsty .POISONTIME // Time until next tick of poison damage .POISONTEXT // Time until next message about suffering from poison .POISONWEAROFF // Time until poison wears off .SPELLTIME // Time until spell cast is completed. Can be set to 0 to interrupt .ANTISPAM // Time until next speech message can be sent (for anti spam purposes) .CRIMFLAG // Time until criminal flag runs out .MURDERRATE // Time until next murder count decay .PEACETIMER // Time until character can re-enter combat after being affected by peacemaking .FLYINGTOGGLE // Time until next time flying ability can be toggled for gargoyles .MOVETIME // Time until NPC can move again .SPATIMER // Time until next time NPC can cast a spell .SUMMONTIME // Time until a summoned NPC will vanish .EVADETIME // Time until an NPC will exit evade state .LOGOUT // Time it takes for a player char to vanish after logout Examples of use: var hungerTimer = myChar.GetTimer( Timer.HUNGER ) myChar.SetTimer( Timer.HUNGER, 15000 ) Added new Character JS Methods to add, remove and list friends of a pet/hireling: .AddFriend( playerToAdd ) // Adds player to friend list .RemoveFriend( playerToRemove ) // Removes player from friend list .GetFriendList() // Gets list of friends .ClearFriendList() // Clears list of friends Added new Character JS Method to fetch a player character's list of pets/followers .GetPetList() // Gets list of pets/followers Added new persistent NPC property to keep track of a pet's previous owners, whether those tamed the pet or had it transferred to them. Every time a pet is tamed, or is transferred to a new owner, this list is updated: GenericList< CChar * > petOwnerList Added new Character JS Method to check if a player is on a pet's owner list as a previous owner: .HasBeenOwner( mChar ) Previous owners of a pet can re-tame it with guaranteed chance of success Updated JS Method Refresh() to be usable with both items or characters, to send updated state of object to nearby players Added character tooltip [Guarded] for characters being guarded by a pet/hireling Pets/hirelings that are transferred will now immediately start following their new master instead of wandering freely Pets/hirelings can no longer be transferred between players as long as either party is flagged as a criminal Pets/hirelings can no longer be transferred to dead players Pets/hirelings can no longer be transferred to NPCs Summoned creatures can no longer be transferred to other players Summoned creatures can no longer have friends Friend lists of pets/hirelings are now cleared when the pet/hireling is transferred to another player Added new UOX.INI settings to control how many pets players can have active: MAXCONTROLSLOTS=0 // Maximum number of pet control slots available to player. Disabled if 0 MAXFOLLOWERS=5 // Maximum pets/followers a player can have active at the same time. Used if control slots are disabled MAXPETOWNERS=5 // Maximum number of different owners a pet can have over its lifetime before it becomes impossible to retame Added new NPC property and NPC DFN tag that keeps track of how many pet control slots an NPC would take up if owned by a player: UI08 controlSlots // source property CONTROLSLOTS=# // DFN tag Added new Character JS properties: .ownerCount // Get the total number of owners a pet/hireling has had, based on NPC's petOwnerList .controlSlots // Get/Set number of pet control slots an NPC will occupy .controlSlotsUsed // Get/Set the number of control slots used by a player Updated get (js/commands/targeting/get.js) and set (js/commands/targeting/set.js) commands to support getting/setting the following character properties: deaths ownerCount (read only) controlSlots controlSlotsUsed Updated NPC DFNs with default CONTROLSLOT=# tags Increased the max distance from player that onSpeech JS event will trigger from 7 to 12 Updated how "all attack" and "all follow" commands for pets are handled. Now loops through all pets owned by character and executes command for each eligible pet Fixed an issue where NPCs could follow characters in different worlds/instances than them selves Updated default max amount of items that can be sold to NPC vendors from 5 to 250 Guards can no longer train players in skills Updated equipment itemlists (dfndata/items/itemlists/itemlists.dfn) with blank entries to introduce some more variety in the type of clothes NPCs wear in general Added new NPCs to DFNs (dfndata/npc/undead.dfn) and added them to undead npclist: [skeletalmage] // variation of [bonemage] [skeletalknight] // variation of [boneknight] Updated Titles (dfndata/titles/titles.dfn) with up-to-date titles for skills around Pub 15, and added titles for skills added after that. Also added "Elder" and "Legendary" titles for 110 and 120 skillpoints Updated EQUIPITEM tag in newbie.dfn (dfndata/newbie/newbie.dfn) to support an optional hue parameter (EQUIPITEM=id,hue) Updated starting equipment for new characters (dfndata/newbie/newbie.dfn), with commented out practice weapons. Uncomment to use Added item definitions for practice weapons (dfndata/items/gear/weapons/practice_weapons.dfn): practice_skinning_knife practice_hatchet practice_axe practice_mace practice_longsword practice_spear practice_bow practice_club practice_crook practice_gnarled_staff Updated mount statues DFN (dfndata/items/misc/mount-statues.dfn) and JS (js/npc/pets/*.js) files to include pet control slot related stuff Pets now inherit the karma of their owners, but revert to their original karma upon release Pets and hirelings will no longer follow the ghosts of their dead owners, but stay to guard their corpse Added optional 9th parameter for JS Function CreateDFNItem to specify a color for item created. This comes before the other optional parameters - worldNumber and instanceID (which are only used if character is NULL): CreateDFNItem( mSock, mChar, sectionName, inPack, iAmount, itemType, iColor, worldNumber, instanceID ) Added ID of Giant Beetle to various pack animal checks Pack animals will now drop any newbie/blessed items stored in their packs upon death Added new NPC properties to track pet loyalty, and exposed these as Character JS properties, and NPC DFN tags: JS Properties .maxLoyalty // Defaults to 100 .loyalty // Starts at 25 DFN Tags MAXLOYALTY=# // Defaults to 100 LOYALTY=# // Starts at 25 Updated TriggerEvent JS function to support return values (int, bool, string, object) from called script Updated various JS scripts to make use of new TriggerEvent functionality and reduce reliance on custom tags: js/item/archerybutte.js js/item/trainingdummy.js js/server/data/combatanims.js js/server/data/weapontypes.js Updated archerybutte script to use dictionary for system and text messages Updated archerybutte script to support increased range, distance penalty and dex/str bonuses when calculating score Added new UOX.INI settings under [pets and hirelings] section related to pet control and loyalty: CHECKPETCONTROLDIFFICULTY=1 // Enable/Disable pet control difficulty system PETLOYALTYGAINONSUCCESS=1 // Amount of pet loyalty gained on successful pet command use PETLOYALTYLOSSONFAILURE=3 // Amount of pet loyalty lost on failed pet command use PETLOYALTYRATE=900 // Amount of seconds between each time pet loyalty is automatically reduced by 1. Takes 25 hours to deplete completely from max Added new persistent NPC property that keeps track of the difficulty of taming and controlling a pet, and exposed it as a Character JS property: .orneriness Every time a tamed pet is released or goes wild, its "orneriness" increases, making it more difficult for other players to tame, and more difficult for anyone to control. Updated CBasePetResponse::canControlPet() function to use pet control difficulty system if enabled, which checks player's animal taming/animal lore skill vs a pet's "orneriness" to determine chance of pet accepting a given pet command On successful use of pet command, increases pet loyalty by value defined in PETLOYALTYGAINONSUCCESS ini setting On failed use of pet command, decreases pet loyalty by value defined in PETLOYALTYLOSSONFAILURE ini setting Added new Character JS Method to calculate chance of a player successfully controlling the pet: .CalculateControlChance( mChar ) // Returns value between 0 and 1000 indicating chance of success Feeding a pet will now restore its loyalty to maximum Pets will now lose loyalty on hunger checks when at maximum hunger Pets that are maximum hungry will now only have a chance to go wild if loyalty has dropped to zero Added new DFN tag for creatures.dfn - TYPE - which contains a string describing the type of creature Added secure pet trading. Players who trade pets will now see a pet transfer deed appear in a secure trade window with the name and type of creature, and upon completion of the trade the associated pet will be instantly transferred to the other player Updated resource JS scripts (js/server/resource/*) to use dictionaries for all system messages Updated skill JS scripts (js/skill/*) to use dictionaries for all system messages Updated housing JS scripts (js/server/house/*) to use dictionaries for all system messages Updated item JS scripts (js/item/*) to use dictionaries for all system messages Updated magic JS scripts (js/magic/*) to use dictionaries for all system messages Updated NPC AI JS scripts (js/npc/ai/*) to use dictionaries for all system messages Updated command JS scripts (js/commands/*) to use dictionaries for all system messages, gump tooltips, etc Updated code to use dictionaries for all system messages Fixed incorrect spelling for UOX.INI setting HIDEW(H)ILEMOUNTED and updated hiding skill (js/skill/hiding.js) to actually allow/disallow hiding while mounted based on this setting Added new Character JS Method to make it easier to make one NPC initiate combat with another: .InitiateCombat( targetChar ) // Character attempts to initiate combat with target character Updated parrying portion of combat code to be in line with Pub15/pre-AoS parrying mechanics. High AR shields now absorb more damage on a successful parry, while low AR shields have a higher chance of parrying. Shields are also now more effective against archery attacks (full absorption potential) than melee attacks (half absorption potential). Updated combat damage calculations to be in line with Pub15/pre-AoS damage calculations Adjusted default value of COMBATNPCDAMAGERATE ini setting (damage divisor when target is a player) from 2 to 1 to account for these changes. Removed dictionary.UNK, and made dictionary.ZRO the default dictionary used for all unsupported languages Added dictionary support for additional languages: Portuguese, Italian, Czech Updated default dictionaries for the following languages: English, French Added default dictionaries for the following languages: German, Spanish, Portuguese, Italian, Czech (note that translations have been provided by automatic services and will contain inaccuracies!) Added new UOX.INI setting to allow specifying a default dictionary language for server, which if set will force that language for all dictionary messages, regardless of client settings: SERVERLANGUAGE=0 // Set default server dictionary language. Supported languages: 0 - None/language used by each client, 1 - English, 2 - German, 3 - Spanish, 5 - French, 6 - Portuguese, 7 - Italian, 8 - Czech Added new function in combat.cpp - AdjustArmorClassDamage() - which adjusts the damage dealt in combat based on whether armour class (AC DFN tag or .ac JS property) of weapon and armour equipped on hit location of target match up. A weapon with armour class 1 would essentially be doubly effective against armour of armour class 1. Allows setting up things like piercing weapons being better against some armor types than mace weapons, etc. Added new UOX.INI setting under [combat] to enable/disable double damage from armour class bonuses: ARMORCLASSDAMAGEBONUS=0/1 //defaults to 0)
1586 lines
60 KiB
C++
1586 lines
60 KiB
C++
//o-----------------------------------------------------------------------------------------------o
|
|
//| File - cMultiObj.cpp
|
|
//| Date - 28th July, 2000
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Version History
|
|
//|
|
|
//| 1.0 28th July, 2000
|
|
//| Very basically fleshed out
|
|
//| Owner, ban list and object inside support included
|
|
//| Note that lockdown stuff is NOT persistent yet, needs support later on
|
|
//| Best place would be world loading, any locked down objects flagged at time added to multi
|
|
//|
|
|
//| 1.1 28th August, 2000
|
|
//| Function declaration headers
|
|
//| Addition of SetMaxLockDowns
|
|
//|
|
|
//| 1.2 30th November, 2000
|
|
//| Changed lock downs to a vector, and full vector support added
|
|
//| Save needs modification
|
|
//|
|
|
//| 1.3 25th September 2003
|
|
//| Added CBoatObj as a derived class of CMultiObj to simplify some processes in the cBoat class
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
#include "uox3.h"
|
|
#include "mapstuff.h"
|
|
|
|
const UI16 DEFMULTI_MAXLOCKDOWNS = 256;
|
|
const UI16 DEFMULTI_MAXSECURECONTAINERS = 4;
|
|
const UI16 DEFMULTI_MAXFRIENDS = 50;
|
|
const UI16 DEFMULTI_MAXGUESTS = 50;
|
|
const UI16 DEFMULTI_MAXOWNERS = 8;
|
|
const UI16 DEFMULTI_MAXBANS = 50;
|
|
const UI16 DEFMULTI_MAXVENDORS = 10;
|
|
const UI16 DEFMULTI_MAXTRASHCONTAINERS = 1;
|
|
const UI16 DEFMULTI_BANX = 0;
|
|
const UI16 DEFMULTI_BANY = 0;
|
|
const time_t DEFMULTI_TRADETIMESTAMP = (time_t)(-1);
|
|
|
|
const UI08 HOUSEPRIV_OWNER = 0;
|
|
const UI08 HOUSEPRIV_BANNED = 1;
|
|
const UI08 HOUSEPRIV_FRIEND = 2;
|
|
const UI08 HOUSEPRIV_GUEST = 3;
|
|
|
|
CMultiObj::CMultiObj() : CItem(), deed( "" ), maxLockdowns( DEFMULTI_MAXLOCKDOWNS ), maxSecureContainers( DEFMULTI_MAXSECURECONTAINERS ),
|
|
maxFriends( DEFMULTI_MAXFRIENDS ), maxGuests( DEFMULTI_MAXGUESTS ), maxOwners( DEFMULTI_MAXOWNERS ), maxBans( DEFMULTI_MAXBANS ), maxVendors( DEFMULTI_MAXVENDORS ),
|
|
maxTrashContainers( DEFMULTI_MAXTRASHCONTAINERS ), banX( DEFMULTI_BANX ), banY( DEFMULTI_BANY ), isPublic( false ), tradeTimestamp( DEFMULTI_TRADETIMESTAMP )
|
|
{
|
|
objType = OT_MULTI;
|
|
housePrivList.clear();
|
|
}
|
|
|
|
CMultiObj::~CMultiObj()
|
|
{
|
|
housePrivList.clear();
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - void AddToBanList( CChar *toBan )
|
|
//| Date - 28th July, 2000
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Adds a character to the ban list
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
void CMultiObj::AddToBanList( CChar *toBan )
|
|
{
|
|
// Restrictions handled through JS
|
|
housePrivList[toBan] = HOUSEPRIV_BANNED;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - void RemoveFromBanList( CChar *toRemove )
|
|
//| Date - 28th July, 2000
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Removes a character from a ban list
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
void CMultiObj::RemoveFromBanList( CChar *toRemove )
|
|
{
|
|
std::map< CChar *, UI08 >::iterator rIter = housePrivList.find( toRemove );
|
|
if( rIter != housePrivList.end() )
|
|
{
|
|
if( rIter->second == HOUSEPRIV_BANNED )
|
|
housePrivList.erase( rIter );
|
|
}
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - void ClearBanList( void )
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Clears ban list
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
void CMultiObj::ClearBanList( void )
|
|
{
|
|
for (auto it = housePrivList.cbegin(), next_it = it; it != housePrivList.cend(); it = next_it)
|
|
{
|
|
++next_it;
|
|
if( it->second == HOUSEPRIV_BANNED )
|
|
{
|
|
housePrivList.erase( it );
|
|
}
|
|
}
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - void AddAsOwner( CChar *newOwner )
|
|
//| Date - 28th July, 2000
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Adds a player as an owner
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
void CMultiObj::AddAsOwner( CChar *newOwner )
|
|
{
|
|
housePrivList[newOwner] = HOUSEPRIV_OWNER;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - void RemoveAsOwner( CChar *toRemove )
|
|
//| Date - 28th July, 2000
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Removes a character from the owner's list
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
void CMultiObj::RemoveAsOwner( CChar *toRemove )
|
|
{
|
|
std::map< CChar *, UI08 >::iterator rIter = housePrivList.find( toRemove );
|
|
if( rIter != housePrivList.end() )
|
|
{
|
|
if( rIter->second == HOUSEPRIV_OWNER )
|
|
housePrivList.erase( rIter );
|
|
}
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - void ClearOwnerList( void )
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Clears co-owner list
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
void CMultiObj::ClearOwnerList( void )
|
|
{
|
|
for (auto it = housePrivList.cbegin(), next_it = it; it != housePrivList.cend(); it = next_it)
|
|
{
|
|
++next_it;
|
|
if( it->second == HOUSEPRIV_OWNER )
|
|
{
|
|
if( owner != it->first->GetSerial() ) // Don't clear primary house owner from list!
|
|
housePrivList.erase( it );
|
|
}
|
|
}
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - void AddAsFriend( CChar *newFriend )
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Adds a player as a friend
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
void CMultiObj::AddAsFriend( CChar *newFriend )
|
|
{
|
|
housePrivList[newFriend] = HOUSEPRIV_FRIEND;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - void RemoveAsFriend( CChar *toRemove )
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Removes a character from the friend list
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
void CMultiObj::RemoveAsFriend( CChar *toRemove )
|
|
{
|
|
std::map< CChar *, UI08 >::iterator rIter = housePrivList.find( toRemove );
|
|
if( rIter != housePrivList.end() )
|
|
{
|
|
if( rIter->second == HOUSEPRIV_FRIEND )
|
|
housePrivList.erase( rIter );
|
|
}
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - void ClearFriendList( void )
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Clears friend list
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
void CMultiObj::ClearFriendList( void )
|
|
{
|
|
for (auto it = housePrivList.cbegin(), next_it = it; it != housePrivList.cend(); it = next_it)
|
|
{
|
|
++next_it;
|
|
if( it->second == HOUSEPRIV_FRIEND )
|
|
{
|
|
housePrivList.erase( it );
|
|
}
|
|
}
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - void AddAsGuest( CChar *newGuest )
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Adds a player as a guest
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
void CMultiObj::AddAsGuest( CChar *newGuest )
|
|
{
|
|
housePrivList[newGuest] = HOUSEPRIV_GUEST;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - void RemoveAsGuest( CChar *toRemove )
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Removes a character from the guest list
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
void CMultiObj::RemoveAsGuest( CChar *toRemove )
|
|
{
|
|
std::map< CChar *, UI08 >::iterator rIter = housePrivList.find( toRemove );
|
|
if( rIter != housePrivList.end() )
|
|
{
|
|
if( rIter->second == HOUSEPRIV_GUEST )
|
|
housePrivList.erase( rIter );
|
|
}
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - void ClearGuestList( void )
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Clears guest list
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
void CMultiObj::ClearGuestList( void )
|
|
{
|
|
for (auto it = housePrivList.cbegin(), next_it = it; it != housePrivList.cend(); it = next_it)
|
|
{
|
|
++next_it;
|
|
if( it->second == HOUSEPRIV_GUEST )
|
|
{
|
|
housePrivList.erase( it );
|
|
}
|
|
}
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - bool IsOnBanList( CChar *toBan ) const
|
|
//| Date - 28th July, 2000
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Returns true if a character is on the ban list
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
bool CMultiObj::IsOnBanList( CChar *toBan ) const
|
|
{
|
|
std::map< CChar *, UI08 >::const_iterator bIter = housePrivList.find( toBan );
|
|
if( bIter != housePrivList.end() )
|
|
{
|
|
if( bIter->second == HOUSEPRIV_BANNED )
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - bool IsOnFriendList( CChar *toCheck ) const
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Returns true if a character is on the friend list
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
bool CMultiObj::IsOnFriendList( CChar *toCheck ) const
|
|
{
|
|
std::map< CChar *, UI08 >::const_iterator bIter = housePrivList.find( toCheck );
|
|
if( bIter != housePrivList.end() )
|
|
{
|
|
if( bIter->second == HOUSEPRIV_FRIEND )
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - bool IsOnGuestList( CChar *toCheck ) const
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Returns true if a character is on the guest list
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
bool CMultiObj::IsOnGuestList( CChar *toCheck ) const
|
|
{
|
|
std::map< CChar *, UI08 >::const_iterator bIter = housePrivList.find( toCheck );
|
|
if( bIter != housePrivList.end() )
|
|
{
|
|
if( bIter->second == HOUSEPRIV_GUEST )
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - bool IsOnOwnerList( CChar *toFind ) const
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Returns true if the character is the owner or a co-owner
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
bool CMultiObj::IsOnOwnerList( CChar *toFind ) const
|
|
{
|
|
std::map< CChar *, UI08 >::const_iterator oIter = housePrivList.find( toFind );
|
|
if( oIter != housePrivList.end() )
|
|
{
|
|
if( oIter->second == HOUSEPRIV_OWNER )
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - bool CheckForAccountCoOwnership( CChar *toFind ) const
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Returns true if the player has another character on same account that co-owns house
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
bool CMultiObj::CheckForAccountCoOwnership( CChar *mChar ) const
|
|
{
|
|
UI16 accountNum = mChar->GetAccountNum();
|
|
std::map< CChar *, UI08 >::const_iterator oIter;
|
|
for( oIter = housePrivList.begin(); oIter != housePrivList.end(); ++oIter )
|
|
{
|
|
if( ValidateObject( oIter->first ) )
|
|
{
|
|
// Check if account number of character in list matches our player's account number, and
|
|
// that the character is stored in the list with owner privilege
|
|
if( oIter->first->GetAccountNum() == accountNum && oIter->second == HOUSEPRIV_OWNER )
|
|
{
|
|
// Make sure it's not the actual owner of the house, though
|
|
if( !IsOwner( oIter->first ))
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - bool IsOwner( CChar *toFind ) const
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Returns true if the character is the actual owner of the house, and not a co-owner
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
bool CMultiObj::IsOwner( CChar *toFind ) const
|
|
{
|
|
return ( owner == toFind->GetSerial() );
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - void AddToMulti( CBaseObject *toAdd )
|
|
//| Date - 28th July, 2000
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Adds an item or character to the multi
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
void CMultiObj::AddToMulti( CBaseObject *toAdd )
|
|
{
|
|
if( toAdd->GetObjType() == OT_CHAR )
|
|
charInMulti.Add( static_cast< CChar * >(toAdd) );
|
|
else
|
|
itemInMulti.Add( static_cast< CItem * >(toAdd) );
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - void RemoveFromMulti( CBaseObject *toRemove )
|
|
//| Date - 28th July, 2000
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Removes an item or character from the multi, if possible
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
void CMultiObj::RemoveFromMulti( CBaseObject *toRemove )
|
|
{
|
|
if( toRemove->GetObjType() == OT_CHAR )
|
|
{
|
|
charInMulti.Remove( static_cast< CChar * >(toRemove) );
|
|
if( CanBeObjType( OT_BOAT ) && charInMulti.Num() == 0 )
|
|
{
|
|
if( (static_cast<CBoatObj *>(this))->GetMoveType() != -1 )
|
|
{
|
|
(static_cast<CBoatObj *>(this))->SetMoveType( 0 );
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if( static_cast< CItem * >(toRemove)->GetTempVar( CITV_MORE ) != serial ) // Prevent doors and signs from being accidentally removed from house!
|
|
{
|
|
itemInMulti.Remove( static_cast< CItem * >(toRemove) );
|
|
}
|
|
}
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - size_t GetLockdownCount( void ) const
|
|
//| Date - 28th July, 2000
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Returns a count of the locked down items
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
size_t CMultiObj::GetLockdownCount( void ) const
|
|
{
|
|
return lockedList.size();
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - UI16 GetMaxLockdowns( void ) const
|
|
//| Date - 28th July, 2000
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Returns the maximum number of possible lockdowns
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
UI16 CMultiObj::GetMaxLockdowns( void ) const
|
|
{
|
|
return maxLockdowns;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - size_t GetTrashContainerCount( void ) const
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Returns a count of the locked down items
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
size_t CMultiObj::GetTrashContainerCount( void ) const
|
|
{
|
|
return trashContainerList.size();
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - UI16 GetMaxTrashContainers( void ) const
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Returns the maximum number of possible trash containers
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
UI16 CMultiObj::GetMaxTrashContainers( void ) const
|
|
{
|
|
return maxTrashContainers;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - size_t GetVendorCount( void ) const
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Returns a count of the player vendors in the multi
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
size_t CMultiObj::GetVendorCount( void ) const
|
|
{
|
|
return vendorList.size();
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - UI16 GetMaxVendors( void ) const
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Removes a player vendor from the multi
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
UI16 CMultiObj::GetMaxVendors( void ) const
|
|
{
|
|
return maxVendors;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - UI16 GetFriendCount( void )
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Returns a count of the amount of friends of multi
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
UI16 CMultiObj::GetFriendCount( void )
|
|
{
|
|
UI16 friendCount = 0;
|
|
for( std::map< CChar *, UI08 >::iterator rIter = housePrivList.begin(); rIter != housePrivList.end(); ++rIter )
|
|
{
|
|
if( rIter->second == HOUSEPRIV_FRIEND )
|
|
friendCount++;
|
|
}
|
|
return friendCount;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - UI16 GetMaxFriends( void ) const
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Returns the maximum number of friends multi can have
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
UI16 CMultiObj::GetMaxFriends( void ) const
|
|
{
|
|
return maxFriends;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - UI16 GetGuestCount( void )
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Returns a count of the amount of guests of multi
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
UI16 CMultiObj::GetGuestCount( void )
|
|
{
|
|
UI16 guestCount = 0;
|
|
for( std::map< CChar *, UI08 >::iterator rIter = housePrivList.begin(); rIter != housePrivList.end(); ++rIter )
|
|
{
|
|
if( rIter->second == HOUSEPRIV_GUEST )
|
|
guestCount++;
|
|
}
|
|
return guestCount;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - UI16 GetMaxGuests( void ) const
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Returns the maximum number of guests multi can have
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
UI16 CMultiObj::GetMaxGuests( void ) const
|
|
{
|
|
return maxGuests;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - UI16 GetBanCount( void )
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Returns a count of the amount of banned players of multi
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
UI16 CMultiObj::GetBanCount( void )
|
|
{
|
|
UI16 banCount = 0;
|
|
for( std::map< CChar *, UI08 >::iterator rIter = housePrivList.begin(); rIter != housePrivList.end(); ++rIter )
|
|
{
|
|
if( rIter->second == HOUSEPRIV_BANNED )
|
|
banCount++;
|
|
}
|
|
return banCount;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - UI16 GetMaxBans( void ) const
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Returns the maximum number of banned players multi can have
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
UI16 CMultiObj::GetMaxBans( void ) const
|
|
{
|
|
return maxBans;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - UI16 GetOwnerCount( void )
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Returns a count of the amount of co-owners of multi
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
UI16 CMultiObj::GetOwnerCount( void )
|
|
{
|
|
UI16 ownerCount = 0;
|
|
for( std::map< CChar *, UI08 >::iterator rIter = housePrivList.begin(); rIter != housePrivList.end(); ++rIter )
|
|
{
|
|
if( rIter->second == HOUSEPRIV_OWNER )
|
|
{
|
|
// Don't count primary house owner as co-owner
|
|
if( rIter->first->GetSerial() != owner )
|
|
ownerCount++;
|
|
}
|
|
}
|
|
return ownerCount;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - UI16 GetMaxOwners( void ) const
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Returns the maximum number of co-owners multi can have
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
UI16 CMultiObj::GetMaxOwners( void ) const
|
|
{
|
|
return maxOwners;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - void LockDownItem( CItem *toLock )
|
|
//| Date - 28th July, 2000
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Locks down an item toLock
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
void CMultiObj::LockDownItem( CItem *toLock )
|
|
{
|
|
if( lockedList.size() < maxLockdowns )
|
|
{
|
|
for( ITEMLIST_CITERATOR lIter = lockedList.begin(); lIter != lockedList.end(); ++lIter )
|
|
{
|
|
if( (*lIter) == toLock )
|
|
return;
|
|
}
|
|
toLock->LockDown();
|
|
toLock->Dirty( UT_UPDATE );
|
|
lockedList.push_back( toLock );
|
|
}
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - void ReleaseItem( CItem *toRemove )
|
|
//| Date - 28th July, 2000
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Unlocks a locked down item
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
void CMultiObj::ReleaseItem( CItem *toRemove )
|
|
{
|
|
for( ITEMLIST_ITERATOR rIter = lockedList.begin(); rIter != lockedList.end(); ++rIter )
|
|
{
|
|
if( (*rIter) == toRemove )
|
|
{
|
|
toRemove->Dirty( UT_UPDATE );
|
|
lockedList.erase( rIter );
|
|
toRemove->SetMovable( 0 );
|
|
toRemove->SetDecayTime( cwmWorldState->ServerData()->BuildSystemTimeValue( tSERVER_DECAYINHOUSE ));
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - void AddTrashContainer( CItem *toAdd )
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Adds a trash container to the multi's trash container list
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
void CMultiObj::AddTrashContainer( CItem *toAdd )
|
|
{
|
|
if( trashContainerList.size() < maxTrashContainers )
|
|
{
|
|
for( ITEMLIST_CITERATOR lIter = trashContainerList.begin(); lIter != trashContainerList.end(); ++lIter )
|
|
{
|
|
if( (*lIter) == toAdd )
|
|
return;
|
|
}
|
|
trashContainerList.push_back( toAdd );
|
|
}
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - void RemoveTrashContainer( CItem *toRemove )
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Unlocks a locked down item
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
void CMultiObj::RemoveTrashContainer( CItem *toRemove )
|
|
{
|
|
for( ITEMLIST_ITERATOR rIter = trashContainerList.begin(); rIter != trashContainerList.end(); ++rIter )
|
|
{
|
|
if( (*rIter) == toRemove )
|
|
{
|
|
trashContainerList.erase( rIter );
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - void AddVendor( CChar *toAdd )
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Adds a player vendor to the multi
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
void CMultiObj::AddVendor( CChar *toAdd )
|
|
{
|
|
if( vendorList.size() < maxVendors )
|
|
{
|
|
for( CHARLIST_CITERATOR lIter = vendorList.begin(); lIter != vendorList.end(); ++lIter )
|
|
{
|
|
if( (*lIter) == toAdd )
|
|
return;
|
|
}
|
|
toAdd->Dirty( UT_UPDATE );
|
|
vendorList.push_back( toAdd );
|
|
}
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - void RemoveVendor( CChar *toRemove )
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Removes a player vendor from the multi
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
void CMultiObj::RemoveVendor( CChar *toRemove )
|
|
{
|
|
for( CHARLIST_ITERATOR rIter = vendorList.begin(); rIter != vendorList.end(); ++rIter )
|
|
{
|
|
if( (*rIter) == toRemove )
|
|
{
|
|
toRemove->Dirty( UT_UPDATE );
|
|
vendorList.erase( rIter );
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - void GetPublicStatus( void ) const
|
|
//| Function - void SetPublicStatus( bool newBool )
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Gets/Sets the public status of the multi - either true (public) or false (private)
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
bool CMultiObj::GetPublicStatus( void ) const
|
|
{
|
|
return isPublic;
|
|
}
|
|
void CMultiObj::SetPublicStatus( bool newBool )
|
|
{
|
|
isPublic = newBool;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - void GetBuildTimestamp( void ) const
|
|
//| Function - void SetBuildTimestamp( bool newBool )
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Gets/Sets the timestamp for when the multi was built
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
std::string CMultiObj::GetBuildTimestamp( void ) const
|
|
{
|
|
if( buildTimestamp > 0 )
|
|
{
|
|
char tempTimestamp[100];
|
|
struct tm * curtime = std::localtime( &buildTimestamp );
|
|
strftime( tempTimestamp, 50, "%F at %T", curtime );
|
|
return tempTimestamp;
|
|
}
|
|
else
|
|
return "Unknown";
|
|
}
|
|
void CMultiObj::SetBuildTimestamp( time_t newTime )
|
|
{
|
|
if( newTime && newTime > 0 )
|
|
buildTimestamp = newTime;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - void GetTradeTimestamp( void ) const
|
|
//| Function - void SetTradeTimestamp( bool newBool )
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Gets/Sets the timestamp for when the multi was last traded between players
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
std::string CMultiObj::GetTradeTimestamp( void ) const
|
|
{
|
|
if( tradeTimestamp > 0 )
|
|
{
|
|
char tempTimestamp[100];
|
|
struct tm * curtime = std::localtime( &tradeTimestamp );
|
|
strftime( tempTimestamp, 50, "%F at %T", curtime );
|
|
return tempTimestamp;
|
|
}
|
|
else
|
|
return "Never";
|
|
}
|
|
void CMultiObj::SetTradeTimestamp( time_t newTime )
|
|
{
|
|
tradeTimestamp = newTime;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - size_t GetSecureContainerCount( void ) const
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Returns a count of the amount of secure containers in the multi
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
size_t CMultiObj::GetSecureContainerCount( void ) const
|
|
{
|
|
return secureContainerList.size();
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - UI16 GetMaxSecureContainers( void ) const
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Returns the maximum number of possible secure containers for a house
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
UI16 CMultiObj::GetMaxSecureContainers( void ) const
|
|
{
|
|
return maxSecureContainers;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - void IsSecureContainer( CItem *toSecure )
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Checks if item is a secure container
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
bool CMultiObj::IsSecureContainer( CItem *toCheck )
|
|
{
|
|
for( ITEMLIST_ITERATOR rIter = secureContainerList.begin(); rIter != secureContainerList.end(); ++rIter )
|
|
{
|
|
if( (*rIter) == toCheck )
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - void SecureContainer( CItem *toSecure )
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Secures specified container
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
void CMultiObj::SecureContainer( CItem *toSecure )
|
|
{
|
|
if( secureContainerList.size() < maxSecureContainers )
|
|
{
|
|
for( ITEMLIST_CITERATOR lIter = secureContainerList.begin(); lIter != secureContainerList.end(); ++lIter )
|
|
{
|
|
if( (*lIter) == toSecure )
|
|
return;
|
|
}
|
|
|
|
if( toSecure->GetType() != 87 ) // Don't lock down trash containers
|
|
{
|
|
toSecure->LockDown();
|
|
}
|
|
toSecure->Dirty( UT_UPDATE );
|
|
secureContainerList.push_back( toSecure );
|
|
}
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - void UnsecureContainer( CItem *toUnsecure )
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Unsecures a secured container
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
void CMultiObj::UnsecureContainer( CItem *toUnsecure )
|
|
{
|
|
for( ITEMLIST_ITERATOR rIter = secureContainerList.begin(); rIter != secureContainerList.end(); ++rIter )
|
|
{
|
|
if( (*rIter) == toUnsecure )
|
|
{
|
|
toUnsecure->Dirty( UT_UPDATE );
|
|
secureContainerList.erase( rIter );
|
|
if( toUnsecure->GetType() != 87 ) // Trash container
|
|
{
|
|
toUnsecure->SetMovable( 1 );
|
|
toUnsecure->SetDecayTime( cwmWorldState->ServerData()->BuildSystemTimeValue( tSERVER_DECAYINHOUSE ));
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - bool Save( std::ofstream &outStream )
|
|
//| Date - 28th July, 2000
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Saves a multi out to disk. outStream is the file to write to
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
bool CMultiObj::Save( std::ofstream &outStream )
|
|
{
|
|
bool rvalue = false;
|
|
if( !isFree() )
|
|
{
|
|
rvalue = true;
|
|
MapData_st& mMap = Map->GetMapData( worldNumber );
|
|
if( GetCont() != nullptr || ( GetX() > 0 && GetX() < mMap.xBlock && GetY() < mMap.yBlock ) )
|
|
{
|
|
DumpHeader( outStream );
|
|
DumpBody( outStream );
|
|
DumpFooter( outStream );
|
|
}
|
|
}
|
|
return rvalue;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - bool LoadRemnants( void )
|
|
//| Date - 20th January, 2002
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - After handling data specific load, other parts go here
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
bool CMultiObj::LoadRemnants( void )
|
|
{
|
|
bool rValue = CItem::LoadRemnants();
|
|
|
|
// Add item weight if item doesn't have it yet
|
|
if( GetWeight() <= 0 )
|
|
SetWeight( 0 );
|
|
return rValue;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - void SetMaxLockdowns( UI16 newValue )
|
|
//| Date - 28th August, 2000
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Sets the maximum number of lockdowns possible
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
void CMultiObj::SetMaxLockdowns( UI16 newValue )
|
|
{
|
|
maxLockdowns = newValue;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - void SetMaxTrashContainers( UI16 newValue )
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Sets the maximum number of trash containers possible
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
void CMultiObj::SetMaxTrashContainers( UI16 newValue )
|
|
{
|
|
maxTrashContainers = newValue;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - void SetMaxVendors( UI16 newValue )
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Sets the maximum number of player vendors possible
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
void CMultiObj::SetMaxVendors( UI16 newValue )
|
|
{
|
|
maxVendors = newValue;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - void SetMaxSecureContainers( UI16 newValue )
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Sets the maximum number of secure containers possible
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
void CMultiObj::SetMaxSecureContainers( UI16 newValue )
|
|
{
|
|
maxSecureContainers = newValue;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - void SetMaxBans( UI16 newValue )
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Sets the maximum number of banned players possible
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
void CMultiObj::SetMaxBans( UI16 newValue )
|
|
{
|
|
maxBans = newValue;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - void SetMaxFriends( UI16 newValue )
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Sets the maximum number of friends possible
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
void CMultiObj::SetMaxFriends( UI16 newValue )
|
|
{
|
|
maxFriends = newValue;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - void SetMaxGuests( UI16 newValue )
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Sets the maximum number of guests possible
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
void CMultiObj::SetMaxGuests( UI16 newValue )
|
|
{
|
|
maxGuests = newValue;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - void SetMaxOwners( UI16 newValue )
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Sets the maximum number of co-owners possible
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
void CMultiObj::SetMaxOwners( UI16 newValue )
|
|
{
|
|
maxOwners = newValue;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - bool DumpHeader( std::ofstream &outStream ) const
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Dumps out the header for the CMultiObj
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
bool CMultiObj::DumpHeader( std::ofstream &outStream ) const
|
|
{
|
|
outStream << "[HOUSE]" << '\n';
|
|
return true;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - bool DumpBody( std::ofstream &outStream ) const
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Writes out all CMultiObj specific information to a world
|
|
//| file. Also prints out the Item and BaseObject portions
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
bool CMultiObj::DumpBody( std::ofstream &outStream ) const
|
|
{
|
|
CItem::DumpBody( outStream );
|
|
|
|
// Hexadecimal Values
|
|
outStream << std::hex;
|
|
|
|
// Decimal / String Values
|
|
outStream << std::dec;
|
|
std::map< CChar *, UI08 >::const_iterator oIter;
|
|
for( oIter = housePrivList.begin(); oIter != housePrivList.end(); ++oIter )
|
|
{
|
|
if( ValidateObject( oIter->first ) )
|
|
{
|
|
if( oIter->second == HOUSEPRIV_OWNER )
|
|
outStream << "Owner=";
|
|
else if( oIter->second == HOUSEPRIV_BANNED )
|
|
outStream << "Banned=";
|
|
else if( oIter->second == HOUSEPRIV_FRIEND )
|
|
outStream << "Friend=";
|
|
else if( oIter->second == HOUSEPRIV_GUEST )
|
|
outStream << "Guest=";
|
|
else
|
|
continue;
|
|
outStream << oIter->first->GetSerial() << '\n';
|
|
}
|
|
}
|
|
outStream << "IsPublic=" << ( isPublic ? "1" : "0" ) << '\n';
|
|
outStream << "MaxBans=" << maxBans << '\n';
|
|
outStream << "MaxFriends=" << maxFriends << '\n';
|
|
outStream << "MaxGuests=" << maxGuests << '\n';
|
|
|
|
ITEMLIST_CITERATOR lIter;
|
|
for( lIter = lockedList.begin(); lIter != lockedList.end(); ++lIter )
|
|
{
|
|
if( ValidateObject( (*lIter) ) )
|
|
outStream << "LockedItem=" << (*lIter)->GetSerial() << '\n';
|
|
}
|
|
|
|
ITEMLIST_CITERATOR lIterSecure;
|
|
for( lIterSecure = secureContainerList.begin(); lIterSecure != secureContainerList.end(); ++lIterSecure )
|
|
{
|
|
if( ValidateObject( (*lIterSecure) ) )
|
|
outStream << "SecureContainer=" << (*lIterSecure)->GetSerial() << '\n';
|
|
}
|
|
|
|
outStream << "MaxLockdowns=" << maxLockdowns << '\n';
|
|
outStream << "MaxSecureContainers=" << maxSecureContainers << '\n';
|
|
|
|
CHARLIST_CITERATOR lIterVendor;
|
|
for( lIterVendor = vendorList.begin(); lIterVendor != vendorList.end(); ++lIterVendor )
|
|
{
|
|
if( ValidateObject( (*lIterVendor) ) )
|
|
outStream << "Vendor=" << (*lIterVendor)->GetSerial() << '\n';
|
|
}
|
|
|
|
outStream << "MaxVendors=" << maxVendors << '\n';
|
|
// Add deedname= to the save :) We need a way to preserve the name of the item
|
|
outStream << "DeedName=" << deed << '\n';
|
|
outStream << "BuildTime=" << buildTimestamp << '\n';
|
|
outStream << "TradeTime=" << tradeTimestamp << '\n';
|
|
return true;
|
|
}
|
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - bool HandleLine( std::string &UTag, std::string &data )
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Processes a tag/data pair if it can. If it can, returns
|
|
//| true. Otherwise, returns false.
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
bool CMultiObj::HandleLine( std::string &UTag, std::string &data )
|
|
{
|
|
bool rvalue = CItem::HandleLine( UTag, data );
|
|
auto csecs = strutil::sections( data, "," );
|
|
|
|
if( !rvalue )
|
|
{
|
|
switch( (UTag.data()[0]) )
|
|
{
|
|
case 'B':
|
|
if( UTag == "BANNED" )
|
|
{
|
|
CChar *bList = calcCharObjFromSer( static_cast<UI32>(std::stoul(strutil::trim( strutil::removeTrailing( data, "//" )), nullptr, 0)) );
|
|
if( ValidateObject( bList ))
|
|
{
|
|
AddToBanList( bList );
|
|
}
|
|
rvalue = true;
|
|
}
|
|
else if( UTag == "BUILDTIME" )
|
|
{
|
|
time_t buildTime = static_cast<UI64>(std::stoll(strutil::trim( strutil::removeTrailing( data, "//" )), nullptr, 0));
|
|
if( buildTime > 0 )
|
|
{
|
|
SetBuildTimestamp( buildTime );
|
|
}
|
|
rvalue = true;
|
|
}
|
|
break;
|
|
case 'C':
|
|
if( UTag == "COOWNER" ) // Legacy tag for loading older data
|
|
{
|
|
CChar *cList = calcCharObjFromSer( static_cast<UI32>(std::stoul(strutil::trim( strutil::removeTrailing( data, "//" )), nullptr, 0)) );
|
|
if( ValidateObject( cList ))
|
|
{
|
|
AddAsOwner( cList );
|
|
}
|
|
rvalue = true;
|
|
}
|
|
break;
|
|
case 'D':
|
|
if( UTag == "DEEDNAME" )
|
|
{
|
|
SetDeed( data );
|
|
rvalue = true;
|
|
}
|
|
break;
|
|
case 'F':
|
|
if( UTag == "FRIEND" )
|
|
{
|
|
CChar *cList = calcCharObjFromSer( static_cast<UI32>(std::stoul(strutil::trim( strutil::removeTrailing( data, "//" )), nullptr, 0)) );
|
|
if( ValidateObject( cList ))
|
|
{
|
|
AddAsFriend( cList );
|
|
}
|
|
rvalue = true;
|
|
}
|
|
break;
|
|
case 'G':
|
|
if( UTag == "GUEST" )
|
|
{
|
|
CChar *cList = calcCharObjFromSer( static_cast<UI32>(std::stoul(strutil::trim( strutil::removeTrailing( data, "//" )), nullptr, 0)) );
|
|
if( ValidateObject( cList ))
|
|
{
|
|
AddAsGuest( cList );
|
|
}
|
|
rvalue = true;
|
|
}
|
|
break;
|
|
case 'I':
|
|
if( UTag == "ISPUBLIC" )
|
|
{
|
|
SetPublicStatus( static_cast<UI16>(std::stoul(strutil::trim( strutil::removeTrailing( data, "//" )), nullptr, 0)) == 1 );
|
|
rvalue = true;
|
|
}
|
|
break;
|
|
case 'L':
|
|
if( UTag == "LOCKEDITEM" )
|
|
{
|
|
CItem *iList = calcItemObjFromSer( static_cast<UI32>(std::stoul(strutil::trim( strutil::removeTrailing( data, "//" )), nullptr, 0)) );
|
|
if( ValidateObject( iList ) )
|
|
LockDownItem( iList );
|
|
rvalue = true;
|
|
}
|
|
break;
|
|
case 'M':
|
|
if( UTag == "MAXBANS" )
|
|
{
|
|
maxBans = static_cast<UI16>(std::stoul(strutil::trim( strutil::removeTrailing( data, "//" )), nullptr, 0));
|
|
rvalue = true;
|
|
}
|
|
else if( UTag == "MAXFRIENDS" )
|
|
{
|
|
maxFriends = static_cast<UI16>(std::stoul(strutil::trim( strutil::removeTrailing( data, "//" )), nullptr, 0));
|
|
rvalue = true;
|
|
}
|
|
else if( UTag == "MAXGUESTS" )
|
|
{
|
|
maxGuests = static_cast<UI16>(std::stoul(strutil::trim( strutil::removeTrailing( data, "//" )), nullptr, 0));
|
|
rvalue = true;
|
|
}
|
|
else if( UTag == "MAXLOCKDOWNS" || UTag == "MAXLOCKEDDOWN" )
|
|
{
|
|
maxLockdowns = static_cast<UI16>(std::stoul(strutil::trim( strutil::removeTrailing( data, "//" )), nullptr, 0));
|
|
rvalue = true;
|
|
}
|
|
else if( UTag == "MAXOWNERS" )
|
|
{
|
|
maxOwners = static_cast<UI16>(std::stoul(strutil::trim( strutil::removeTrailing( data, "//" )), nullptr, 0));
|
|
rvalue = true;
|
|
}
|
|
else if( UTag == "MAXSECURECONTAINERS" )
|
|
{
|
|
maxSecureContainers = static_cast<UI16>(std::stoul(strutil::trim( strutil::removeTrailing( data, "//" )), nullptr, 0));
|
|
rvalue = true;
|
|
}
|
|
else if( UTag == "MAXVENDORS" )
|
|
{
|
|
maxVendors = static_cast<UI16>(std::stoul(strutil::trim( strutil::removeTrailing( data, "//" )), nullptr, 0));
|
|
rvalue = true;
|
|
}
|
|
break;
|
|
case 'O':
|
|
if( UTag == "OWNER" )
|
|
{
|
|
CChar *cList = calcCharObjFromSer( static_cast<UI32>(std::stoul(strutil::trim( strutil::removeTrailing( data, "//" )), nullptr, 0)) );
|
|
if( ValidateObject( cList ))
|
|
{
|
|
AddAsOwner( cList );
|
|
}
|
|
rvalue = true;
|
|
}
|
|
break;
|
|
case 'S':
|
|
if( UTag == "SECURECONTAINER" )
|
|
{
|
|
CItem *iList = calcItemObjFromSer( static_cast<UI32>(std::stoul(strutil::trim( strutil::removeTrailing( data, "//" )), nullptr, 0)) );
|
|
if( ValidateObject( iList ))
|
|
{
|
|
SecureContainer( iList );
|
|
}
|
|
rvalue = true;
|
|
}
|
|
break;
|
|
case 'T':
|
|
if( UTag == "TRADETIME" )
|
|
{
|
|
time_t tradeTime = static_cast<UI64>(std::stoll(strutil::trim( strutil::removeTrailing( data, "//" )), nullptr, 0));
|
|
if( tradeTime > 0 )
|
|
{
|
|
SetTradeTimestamp( tradeTime );
|
|
}
|
|
rvalue = true;
|
|
}
|
|
break;
|
|
case 'V':
|
|
if( UTag == "VENDOR" )
|
|
{
|
|
CChar *cList = calcCharObjFromSer( static_cast<UI32>(std::stoul(strutil::trim( strutil::removeTrailing( data, "//" )), nullptr, 0)) );
|
|
if( ValidateObject( cList ) )
|
|
AddVendor( cList );
|
|
rvalue = true;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
return rvalue;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - void SetOwner( CChar *newOwner )
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Ensures that newOwner is also on the house ownership list.
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
void CMultiObj::SetOwner( CChar *newOwner )
|
|
{
|
|
RemoveSelfFromOwner(); // Remove multi from previous owner's list of owned items
|
|
if( ValidateObject( newOwner ) )
|
|
{
|
|
owner = newOwner->GetSerial();
|
|
AddAsOwner( newOwner );
|
|
AddSelfToOwner(); // Add multi to owner's list of owned items
|
|
}
|
|
else
|
|
owner = INVALIDSERIAL;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - void Cleanup( void )
|
|
//| Date - 26th September, 2001
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Makes sure that any items and chars inside the multi are removed
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
void CMultiObj::Cleanup( void )
|
|
{
|
|
for( CItem *iRemove = itemInMulti.First(); !itemInMulti.Finished(); iRemove = itemInMulti.Next() )
|
|
{
|
|
if( ValidateObject( iRemove ) )
|
|
{
|
|
ItemTypes iType = iRemove->GetType();
|
|
if( iType == IT_DOOR || iType == IT_LOCKEDDOOR || iType == IT_HOUSESIGN )
|
|
iRemove->Delete();
|
|
else
|
|
{
|
|
if( iRemove->IsLockedDown() )
|
|
iRemove->SetMovable( 1 );
|
|
iRemove->SetMulti( INVALIDSERIAL, false );
|
|
iRemove->SetZ( GetZ() );
|
|
}
|
|
}
|
|
}
|
|
for( CChar *cRemove = charInMulti.First(); !charInMulti.Finished(); cRemove = charInMulti.Next() )
|
|
{
|
|
if( ValidateObject( cRemove ) )
|
|
{
|
|
cRemove->SetMulti( INVALIDSERIAL, false );
|
|
cRemove->SetZ( GetZ() );
|
|
}
|
|
}
|
|
CItem::Cleanup();
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - std::string GetDeed( void ) const
|
|
//| void SetDeed( const std::string &newDeed )
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Gets/Sets item ID of multi's deed item, for converting multi to/from deed
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
std::string CMultiObj::GetDeed( void ) const
|
|
{
|
|
return deed;
|
|
}
|
|
void CMultiObj::SetDeed( const std::string &newDeed )
|
|
{
|
|
deed = newDeed;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - bool CanBeObjType( ObjectType toCompare ) const
|
|
//| Date - 24 June, 2004
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Indicates whether an object can behave as a particular type
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
bool CMultiObj::CanBeObjType( ObjectType toCompare ) const
|
|
{
|
|
bool rvalue = CItem::CanBeObjType( toCompare );
|
|
if( !rvalue )
|
|
{
|
|
if( toCompare == OT_MULTI )
|
|
rvalue = true;
|
|
}
|
|
return rvalue;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - SI16 GetBanX( void ) const
|
|
//| void SetBanX( SI16 newValue )
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Gets/Sets the X offset for multi's ban location
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
SI16 CMultiObj::GetBanX( void ) const
|
|
{
|
|
return banX;
|
|
}
|
|
void CMultiObj::SetBanX( SI16 newValue )
|
|
{
|
|
banX = newValue;
|
|
}
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - SI16 GetBanY( void ) const
|
|
//| void SetBanY( SI16 newValue )
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Gets/Sets the Y offset for multi's ban location
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
SI16 CMultiObj::GetBanY( void ) const
|
|
{
|
|
return banY;
|
|
}
|
|
void CMultiObj::SetBanY( SI16 newValue )
|
|
{
|
|
banY = newValue;
|
|
}
|
|
|
|
GenericList< CChar * > * CMultiObj::GetOwnersOfMultiList( bool clearList )
|
|
{
|
|
if( clearList )
|
|
{
|
|
ownersOfMulti.Clear();
|
|
|
|
for (auto it = housePrivList.cbegin(), next_it = it; it != housePrivList.cend(); it = next_it)
|
|
{
|
|
++next_it;
|
|
if( it->second == HOUSEPRIV_OWNER )
|
|
{
|
|
ownersOfMulti.Add( static_cast< CChar * >(it->first) );
|
|
}
|
|
}
|
|
}
|
|
|
|
return &ownersOfMulti;
|
|
}
|
|
|
|
GenericList< CChar * > * CMultiObj::GetFriendsOfMultiList( bool clearList )
|
|
{
|
|
if( clearList )
|
|
friendsOfMulti.Clear();
|
|
|
|
for (auto it = housePrivList.cbegin(), next_it = it; it != housePrivList.cend(); it = next_it)
|
|
{
|
|
++next_it;
|
|
if( it->second == HOUSEPRIV_FRIEND )
|
|
{
|
|
friendsOfMulti.Add( static_cast< CChar * >(it->first) );
|
|
}
|
|
}
|
|
|
|
return &friendsOfMulti;
|
|
}
|
|
|
|
GenericList< CChar * > * CMultiObj::GetGuestsOfMultiList( bool clearList )
|
|
{
|
|
if( clearList )
|
|
guestsOfMulti.Clear();
|
|
|
|
for (auto it = housePrivList.cbegin(), next_it = it; it != housePrivList.cend(); it = next_it)
|
|
{
|
|
++next_it;
|
|
if( it->second == HOUSEPRIV_GUEST )
|
|
{
|
|
guestsOfMulti.Add( static_cast< CChar * >(it->first) );
|
|
}
|
|
}
|
|
|
|
return &guestsOfMulti;
|
|
}
|
|
|
|
GenericList< CChar * > * CMultiObj::GetBannedFromMultiList( bool clearList )
|
|
{
|
|
if( clearList )
|
|
bannedFromMulti.Clear();
|
|
|
|
for (auto it = housePrivList.cbegin(), next_it = it; it != housePrivList.cend(); it = next_it)
|
|
{
|
|
++next_it;
|
|
if( it->second == HOUSEPRIV_BANNED )
|
|
{
|
|
bannedFromMulti.Add( static_cast< CChar * >(it->first) );
|
|
}
|
|
}
|
|
|
|
return &bannedFromMulti;
|
|
}
|
|
|
|
GenericList< CChar * > * CMultiObj::GetCharsInMultiList( void )
|
|
{
|
|
return &charInMulti;
|
|
}
|
|
|
|
GenericList< CItem * > * CMultiObj::GetItemsInMultiList( void )
|
|
{
|
|
return &itemInMulti;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Class - CBoatObj
|
|
//| Date - 25th September, 2003
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Version History
|
|
//|
|
|
//| 1.0 25th September, 2003
|
|
//| Very basic, currently
|
|
//| Simplifies some processes in cBoat class, eventually should allow
|
|
//| easy removal of some generic containers in CItem class
|
|
//|
|
|
//| 1.1 28th October, 2003
|
|
//| Added MoveType() to remove the need for CItem::Type2()
|
|
//| Added MoveTime() instead of using CItem::GateTime()
|
|
//| Changed Plank1() and Plank2() to Plank() using an array
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
const SERIAL DEFBOAT_TILLER = INVALIDSERIAL;
|
|
const SERIAL DEFBOAT_HOLD = INVALIDSERIAL;
|
|
const SI08 DEFBOAT_MOVETYPE = 0;
|
|
const TIMERVAL DEFBOAT_MOVETIME = 0;
|
|
|
|
CBoatObj::CBoatObj() : CMultiObj(), tiller( DEFBOAT_TILLER ), hold( DEFBOAT_HOLD ),
|
|
moveType( DEFBOAT_MOVETYPE ), nextMoveTime( DEFBOAT_MOVETIME )
|
|
{
|
|
planks[0] = planks[1] = INVALIDSERIAL;
|
|
objType = OT_BOAT;
|
|
}
|
|
|
|
CBoatObj::~CBoatObj()
|
|
{
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - bool DumpHeader( std::ofstream &outStream ) const
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Dumps out the header for the CMultiObj
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
bool CBoatObj::DumpHeader( std::ofstream &outStream ) const
|
|
{
|
|
outStream << "[BOAT]" << '\n';
|
|
return true;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - bool DumpBody( std::ofstream &outStream ) const
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Writes out all CMultiObj specific information to a world
|
|
//| file. Also prints out the Item and BaseObject portions
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
bool CBoatObj::DumpBody( std::ofstream &outStream ) const
|
|
{
|
|
CMultiObj::DumpBody( outStream );
|
|
|
|
// Hexadecimal Values
|
|
outStream << std::hex;
|
|
outStream << "Hold=" << "0x" << hold << '\n';
|
|
outStream << "Planks=" << "0x" << planks[0] << ",0x" << planks[1] << '\n';
|
|
outStream << "Tiller=" << "0x" << tiller << std::dec << '\n';
|
|
|
|
// Decimal / String Values
|
|
outStream << std::dec;
|
|
return true;
|
|
}
|
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - bool HandleLine( std::string &UTag,std::string &data )
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Processes a tag/data pair if it can. If it can, returns
|
|
//| true. Otherwise, returns false.
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
bool CBoatObj::HandleLine( std::string &UTag,std::string &data )
|
|
{
|
|
bool rvalue = CMultiObj::HandleLine( UTag, data );
|
|
if( !rvalue )
|
|
{
|
|
auto csecs = strutil::sections( data, "," );
|
|
switch( (UTag.data()[0]) )
|
|
{
|
|
case 'M':
|
|
if( UTag == "MOVETYPE" )
|
|
{
|
|
rvalue = true;
|
|
}
|
|
break;
|
|
case 'H':
|
|
if( UTag == "HOLD" )
|
|
{
|
|
SetHold( static_cast<UI32>(std::stoul(strutil::trim( strutil::removeTrailing( data, "//" )), nullptr, 0)) );
|
|
rvalue = true;
|
|
}
|
|
break;
|
|
case 'P':
|
|
if( UTag == "PLANKS" )
|
|
{
|
|
SetPlank( 0, static_cast<UI32>(std::stoul(strutil::trim( strutil::removeTrailing( csecs[0], "//" )), nullptr, 0)) );
|
|
SetPlank( 1, static_cast<UI32>(std::stoul(strutil::trim( strutil::removeTrailing( csecs[1], "//" )), nullptr, 0)) );
|
|
rvalue = true;
|
|
}
|
|
break;
|
|
case 'T':
|
|
if( UTag == "TILLER" )
|
|
{
|
|
SetTiller( strutil::value<std::uint32_t>(data) );
|
|
rvalue = true;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
return rvalue;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - SERIAL GetTiller( void ) const
|
|
//| void SetTiller( SERIAL newVal )
|
|
//| Date - September 25, 2003
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Gets/Sets boat's Tiller item reference
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
SERIAL CBoatObj::GetTiller( void ) const
|
|
{
|
|
return tiller;
|
|
}
|
|
void CBoatObj::SetTiller( SERIAL newVal )
|
|
{
|
|
tiller = newVal;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - SERIAL GetPlank( UI08 plankNum ) const
|
|
//| void SetPlank( UI08 plankNum, SERIAL newVal )
|
|
//| Date - September 25, 2003
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Gets/Sets boat's Plank item reference
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
SERIAL CBoatObj::GetPlank( UI08 plankNum ) const
|
|
{
|
|
SERIAL rvalue = INVALIDSERIAL;
|
|
if( plankNum < 2 )
|
|
rvalue = planks[plankNum];
|
|
return rvalue;
|
|
}
|
|
void CBoatObj::SetPlank( UI08 plankNum, SERIAL newVal )
|
|
{
|
|
if( plankNum < 2 )
|
|
planks[plankNum] = newVal;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - SERIAL GetHold( void ) const
|
|
//| void SetHold( SERIAL newVal )
|
|
//| Date - September 25, 2003
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Gets/Sets boat's Hold item reference
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
SERIAL CBoatObj::GetHold( void ) const
|
|
{
|
|
return hold;
|
|
}
|
|
void CBoatObj::SetHold( SERIAL newVal )
|
|
{
|
|
hold = newVal;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - SI08 GetMoveType( void ) const
|
|
//| void SetMoveType( SI08 newVal )
|
|
//| Date - October 28, 2003
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Gets/Sets boat's movement type. See BoatMoveType enum for full list
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
SI08 CBoatObj::GetMoveType( void ) const
|
|
{
|
|
return moveType;
|
|
}
|
|
void CBoatObj::SetMoveType( SI08 newVal )
|
|
{
|
|
moveType = newVal;
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - TIMERVAL GetMoveTime( void ) const
|
|
//| void SetMoveTime( TIMERVAL newVal )
|
|
//| Date - October 28, 2003
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Gets/Sets time for when boat will move next
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
TIMERVAL CBoatObj::GetMoveTime( void ) const
|
|
{
|
|
return nextMoveTime;
|
|
}
|
|
void CBoatObj::SetMoveTime( TIMERVAL newVal )
|
|
{
|
|
nextMoveTime = newVal;
|
|
}
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - bool CanBeObjType( ObjectType toCompare ) const
|
|
//| Date - 24 June, 2004
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Indicates whether an object can behave as a particular type
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
bool CBoatObj::CanBeObjType( ObjectType toCompare ) const
|
|
{
|
|
bool rvalue = CMultiObj::CanBeObjType( toCompare );
|
|
if( !rvalue )
|
|
{
|
|
if( toCompare == OT_BOAT )
|
|
rvalue = true;
|
|
}
|
|
return rvalue;
|
|
}
|