Added:
-JS Get/Set "vulnerable" handlers for character properties (Abaddon)
-willHunger with Get/Set HungerStatus() wrappers to CChar class (can now
selectively stop a character/creature from continuing to hunger)
-JS Get/Set "willhunger" handlers for character properties Changed:
Linux compile fixes (thanks Malketh)
Hash.h warning fixed (thanks Philantrop)
Fixes to getRootPack() and getPackOwner()
Removed many #includes from the global scope, including them in the specific files that need them
This should greatly reduce compile time and filesize, along with the need to recompile after altering most headers
Removed the linux ifdefs around typedefd function declarations, this should work with gcc 3.2
Moved global loading functions into a new cFileIO() class to take them out of global scope
Fixed an issue causing items to not be sent to the client (thanks Malketh)
Moved some global structs into the CWorldMain class
Fixed a bug causing a crash on character / item creation
Moved all effects stuff into its own class to take it out of global scope
Changed the variable CChar::region to CChar::regionNum to avoid conflicts with the cTownRegion region[] indexes
Moved getbestskill(), isHuman(), and inDungeon() into the CChar class to remove them from global scope
Took npcSimpleAttackTarget() out of global scope
Rewrote restock() to make use of restockNPC()
Changed the typedef'd iterator in hash.h to HASHITERATOR to kill a Linux warning
Renamed cEffects::soundeffect() to PlaySound() and removed unneeded overloads
Fixed a bug causing executebatch to be set with locationcount data
Rewrote cEffects::bgsound()
Documented sounds.cpp
Misc minor cleanups / fixes
Removed:
sendItemsInRange() (CChar::Teleport() does the same thing)
Many #includes that were not being used
deathMenu()
respawnnow() and moved all of its code into command_respawn()
one instance of cEffects::scpSoundEffect() and renamed the other to PlaySound()
3/13/2003
Changed
Fixed an issue allowing the server to not have a dictionary.ZRO (which would cause a crash when a dictionary entry was called with no language)
Fixed an issue causing the server to puke when it attempted a restart
Moved SpawnRandomItem() into cItem class
Moved SpawnRandomMonster() into cCharHandle class
Broke necro.dfn into fishing.dfn and digging.dfn
Made better use of SpawnRandomItem() and SpawnRandomMonster()
3/12/2003
Added:
CPOpenGump and CPSpeech packet class to remove some global vars (Note these are pretty basic classes and someone
with a better understanding of how we handle sending/recieving packets could probably expand these to make better use of them)
Changed:
Moved many global vars into the CWorldMain() class
Cleaned ResetVars() in uox3.cpp as ResetDefaults() in CWorldMain() now handles much of that
Added a check to ensure text wasn't sent twice in talking(), should fix double-speech
Cleaned up cmdtable.cpp removing a couple duplicate entries, etc
Changed target() to only require 4 values (as the first two were always 0 and 1)
Removed many unneeded typedefs and globals
Went through cServerData() and noted unused server.ini entries
Moved title1(), title2(), and title3() to cClick.cpp since that is their only usage, made use
of MAX_TITLE to ensure we wouldn't overrun the buffers, and renamed them matching what title they were
3/11/2003
Changed:
Fixed a potentially very serious bugs with how containers were being set upon loading the world
Fixed possible re-adding of weight to containers and characters at load
Fixed a bug causing equipped items that were not weapons to take damage in combat
Minor cleanups / warning fixes / Linux compatability issues (punt)
3/7/2003
Overhauls/Additions/Major Changes
Changed:
Tweaks/Object Conversions/Misc Small Changes
Changed:
Changed CItem::Get/SetLayer() to a UI08
Fixed a bug in speech causing you to see your own text twice
Fixed a nasty crash bug
2003-03-23 10:18:02 +00:00
|
|
|
#include "uox3.h"
|
2002-04-07 20:53:41 +00:00
|
|
|
#include "cServerDefinitions.h"
|
|
|
|
|
#include "ssection.h"
|
Added:
-JS Get/Set "vulnerable" handlers for character properties (Abaddon)
-willHunger with Get/Set HungerStatus() wrappers to CChar class (can now
selectively stop a character/creature from continuing to hunger)
-JS Get/Set "willhunger" handlers for character properties Changed:
Linux compile fixes (thanks Malketh)
Hash.h warning fixed (thanks Philantrop)
Fixes to getRootPack() and getPackOwner()
Removed many #includes from the global scope, including them in the specific files that need them
This should greatly reduce compile time and filesize, along with the need to recompile after altering most headers
Removed the linux ifdefs around typedefd function declarations, this should work with gcc 3.2
Moved global loading functions into a new cFileIO() class to take them out of global scope
Fixed an issue causing items to not be sent to the client (thanks Malketh)
Moved some global structs into the CWorldMain class
Fixed a bug causing a crash on character / item creation
Moved all effects stuff into its own class to take it out of global scope
Changed the variable CChar::region to CChar::regionNum to avoid conflicts with the cTownRegion region[] indexes
Moved getbestskill(), isHuman(), and inDungeon() into the CChar class to remove them from global scope
Took npcSimpleAttackTarget() out of global scope
Rewrote restock() to make use of restockNPC()
Changed the typedef'd iterator in hash.h to HASHITERATOR to kill a Linux warning
Renamed cEffects::soundeffect() to PlaySound() and removed unneeded overloads
Fixed a bug causing executebatch to be set with locationcount data
Rewrote cEffects::bgsound()
Documented sounds.cpp
Misc minor cleanups / fixes
Removed:
sendItemsInRange() (CChar::Teleport() does the same thing)
Many #includes that were not being used
deathMenu()
respawnnow() and moved all of its code into command_respawn()
one instance of cEffects::scpSoundEffect() and renamed the other to PlaySound()
3/13/2003
Changed
Fixed an issue allowing the server to not have a dictionary.ZRO (which would cause a crash when a dictionary entry was called with no language)
Fixed an issue causing the server to puke when it attempted a restart
Moved SpawnRandomItem() into cItem class
Moved SpawnRandomMonster() into cCharHandle class
Broke necro.dfn into fishing.dfn and digging.dfn
Made better use of SpawnRandomItem() and SpawnRandomMonster()
3/12/2003
Added:
CPOpenGump and CPSpeech packet class to remove some global vars (Note these are pretty basic classes and someone
with a better understanding of how we handle sending/recieving packets could probably expand these to make better use of them)
Changed:
Moved many global vars into the CWorldMain() class
Cleaned ResetVars() in uox3.cpp as ResetDefaults() in CWorldMain() now handles much of that
Added a check to ensure text wasn't sent twice in talking(), should fix double-speech
Cleaned up cmdtable.cpp removing a couple duplicate entries, etc
Changed target() to only require 4 values (as the first two were always 0 and 1)
Removed many unneeded typedefs and globals
Went through cServerData() and noted unused server.ini entries
Moved title1(), title2(), and title3() to cClick.cpp since that is their only usage, made use
of MAX_TITLE to ensure we wouldn't overrun the buffers, and renamed them matching what title they were
3/11/2003
Changed:
Fixed a potentially very serious bugs with how containers were being set upon loading the world
Fixed possible re-adding of weight to containers and characters at load
Fixed a bug causing equipped items that were not weapons to take damage in combat
Minor cleanups / warning fixes / Linux compatability issues (punt)
3/7/2003
Overhauls/Additions/Major Changes
Changed:
Tweaks/Object Conversions/Misc Small Changes
Changed:
Changed CItem::Get/SetLayer() to a UI08
Fixed a bug in speech causing you to see your own text twice
Fixed a nasty crash bug
2003-03-23 10:18:02 +00:00
|
|
|
#include "scriptc.h"
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
#include "StringUtility.hpp"
|
2012-11-03 18:11:04 +00:00
|
|
|
|
2022-06-14 11:36:04 -04:00
|
|
|
#include <filesystem>
|
2022-06-09 08:02:49 -04:00
|
|
|
#include <memory>
|
2022-06-10 10:49:59 -04:00
|
|
|
#include <array>
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
using namespace std::string_literals;
|
2022-06-06 11:27:53 -04:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
CServerDefinitions *FileLookup;
|
2022-10-24 18:39:33 +08:00
|
|
|
//==================================================================================================
|
|
|
|
|
auto CurrentWorkingDir() -> std::string
|
|
|
|
|
{
|
2020-08-14 08:58:15 +08:00
|
|
|
return std::filesystem::current_path().string();
|
2003-03-04 14:55:47 +00:00
|
|
|
}
|
Instance-support and misc code cleanup
Misc code and documentation cleanup:
Updated and standardized function comment blocks throughout entire codebase
Grouped getters and setters together in pairs and documented them as one
Removed empty and/or non-useful information from comment blocks
Removed unused function from cItem.cpp/h - IncID() - formerly used to change IDs for doors
Added new feature - Instances
Objects (characters, items, multis, spawnregions) can now make use of a 5th parameter to determine their location in the game world. In addition to the traditional X, Y, Z and WORLDNUMBER parameters, a new one has been added - INSTANCEID - that allows objects to exist at the same coordinates in the same world, but in different "dimensions". Code has been updated in multiple places to support this, and a default instanceID of 0 is assumed if nothing else is specified.
Added support for new DFN tag in town regions, spawn regions and locations - INSTANCEID (defaults to 0 if not present)
Added support for another start location parameter after worldNum in UOX.INI representing instanceID (defaults to 0 if not present)
Updated TWEAK menu to include WorldNumber and instanceID
Fixed BaseWeight option in TWEAK menu
Updated CBase_Teleport - now takes an optional 5th parameter instanceID
Updated SE_SpawnNPC now takes an optional 5th parameter - instanceID
Updated SE_FindMulti now takes an optional 5th parameter - instanceID
Updated SE_GetItem now takes an optional 5th parameter - instanceID
Updated SE_FindItem now takes an optional 6th parameter - instanceID
Added new JS property for Items, Characters, Regions: .instanceID
Added JS property for Regions: .members - returns comma-separated list of town member serials
Updated JS scripts making use of the above-mentioned JS Methods/Functions
Updated dictionaries with new tweak menu entry texts
Exposed SpawnRegions to JS engine, and updated JS docs with details:
SpawnRegion JS Functions
IterateOverSpawnRegions()
GetSpawnRegion( spawnRegNum )
GetSpawnRegionCount()
SpawnRegion JS Properties
name
regionNum
itemList
npcList
item
npc
maxItems
maxNpcs
itemCount
npcCount
onlyOutside
prefZ
x1
y1
x2
y2
world
instanceID
minTime
maxTime
call
2020-08-08 13:57:15 +08:00
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//==================================================================================================
|
|
|
|
|
auto BuildPath( const std::string &extra ) -> std::string
|
|
|
|
|
{
|
2022-06-14 11:36:04 -04:00
|
|
|
auto temp = std::filesystem::current_path();
|
2022-10-24 18:39:33 +08:00
|
|
|
temp /= std::filesystem::path( extra );
|
2022-06-14 11:36:04 -04:00
|
|
|
return temp.string();
|
2003-03-04 14:55:47 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//==================================================================================================
|
|
|
|
|
auto ShortDirectory( std::string sPath ) -> std::string
|
|
|
|
|
{
|
|
|
|
|
return std::filesystem::path( sPath ).filename().string();
|
2003-03-04 14:55:47 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//==================================================================================================
|
|
|
|
|
const std::array<std::string, NUM_DEFS> dirNames
|
|
|
|
|
{
|
2022-06-10 10:49:59 -04:00
|
|
|
"items"s,
|
|
|
|
|
"npc"s,
|
|
|
|
|
"create"s,
|
|
|
|
|
"regions"s,
|
|
|
|
|
"misc"s,
|
|
|
|
|
"skills"s,
|
|
|
|
|
"location"s,
|
|
|
|
|
"menus"s,
|
|
|
|
|
"spells"s,
|
|
|
|
|
"newbie"s,
|
|
|
|
|
"titles"s,
|
|
|
|
|
"advance"s,
|
|
|
|
|
"house"s,
|
|
|
|
|
"colors"s,
|
|
|
|
|
"spawn"s,
|
|
|
|
|
"html"s,
|
|
|
|
|
"race"s,
|
|
|
|
|
"weather"s,
|
|
|
|
|
"harditems"s,
|
|
|
|
|
"command"s,
|
|
|
|
|
"msgboard"s,
|
|
|
|
|
"carve"s,
|
|
|
|
|
"creatures"s,
|
|
|
|
|
"maps"s
|
2002-04-07 20:53:41 +00:00
|
|
|
};
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
std::multimap<UI32, ADDMENUITEM> g_mmapAddMenuMap;
|
2012-11-03 18:11:04 +00:00
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//==================================================================================================
|
|
|
|
|
CServerDefinitions::CServerDefinitions() : defaultPriority( 0 )
|
|
|
|
|
{
|
2022-06-14 11:36:04 -04:00
|
|
|
}
|
2022-10-24 18:39:33 +08:00
|
|
|
//==================================================================================================
|
|
|
|
|
auto CServerDefinitions::Startup() -> void
|
|
|
|
|
{
|
2002-04-07 20:53:41 +00:00
|
|
|
Console.PrintSectionBegin();
|
|
|
|
|
Console << "Loading server scripts..." << myendl;
|
2022-10-24 18:39:33 +08:00
|
|
|
Console << " o Clearing AddMenuMap entries(" << static_cast<UI64>( g_mmapAddMenuMap.size() ) << ")" << myendl;
|
2012-11-03 18:11:04 +00:00
|
|
|
g_mmapAddMenuMap.clear();
|
2002-04-07 20:53:41 +00:00
|
|
|
ScriptListings.resize( NUM_DEFS );
|
|
|
|
|
ReloadScriptObjects();
|
|
|
|
|
Console.PrintSectionBegin();
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - CServerDefinitions::Reload()
|
Instance-support and misc code cleanup
Misc code and documentation cleanup:
Updated and standardized function comment blocks throughout entire codebase
Grouped getters and setters together in pairs and documented them as one
Removed empty and/or non-useful information from comment blocks
Removed unused function from cItem.cpp/h - IncID() - formerly used to change IDs for doors
Added new feature - Instances
Objects (characters, items, multis, spawnregions) can now make use of a 5th parameter to determine their location in the game world. In addition to the traditional X, Y, Z and WORLDNUMBER parameters, a new one has been added - INSTANCEID - that allows objects to exist at the same coordinates in the same world, but in different "dimensions". Code has been updated in multiple places to support this, and a default instanceID of 0 is assumed if nothing else is specified.
Added support for new DFN tag in town regions, spawn regions and locations - INSTANCEID (defaults to 0 if not present)
Added support for another start location parameter after worldNum in UOX.INI representing instanceID (defaults to 0 if not present)
Updated TWEAK menu to include WorldNumber and instanceID
Fixed BaseWeight option in TWEAK menu
Updated CBase_Teleport - now takes an optional 5th parameter instanceID
Updated SE_SpawnNPC now takes an optional 5th parameter - instanceID
Updated SE_FindMulti now takes an optional 5th parameter - instanceID
Updated SE_GetItem now takes an optional 5th parameter - instanceID
Updated SE_FindItem now takes an optional 6th parameter - instanceID
Added new JS property for Items, Characters, Regions: .instanceID
Added JS property for Regions: .members - returns comma-separated list of town member serials
Updated JS scripts making use of the above-mentioned JS Methods/Functions
Updated dictionaries with new tweak menu entry texts
Exposed SpawnRegions to JS engine, and updated JS docs with details:
SpawnRegion JS Functions
IterateOverSpawnRegions()
GetSpawnRegion( spawnRegNum )
GetSpawnRegionCount()
SpawnRegion JS Properties
name
regionNum
itemList
npcList
item
npc
maxItems
maxNpcs
itemCount
npcCount
onlyOutside
prefZ
x1
y1
x2
y2
world
instanceID
minTime
maxTime
call
2020-08-08 13:57:15 +08:00
|
|
|
//| Date - 04/17/2002
|
2022-10-24 18:39:33 +08:00
|
|
|
//o------------------------------------------------------------------------------------------------o
|
Instance-support and misc code cleanup
Misc code and documentation cleanup:
Updated and standardized function comment blocks throughout entire codebase
Grouped getters and setters together in pairs and documented them as one
Removed empty and/or non-useful information from comment blocks
Removed unused function from cItem.cpp/h - IncID() - formerly used to change IDs for doors
Added new feature - Instances
Objects (characters, items, multis, spawnregions) can now make use of a 5th parameter to determine their location in the game world. In addition to the traditional X, Y, Z and WORLDNUMBER parameters, a new one has been added - INSTANCEID - that allows objects to exist at the same coordinates in the same world, but in different "dimensions". Code has been updated in multiple places to support this, and a default instanceID of 0 is assumed if nothing else is specified.
Added support for new DFN tag in town regions, spawn regions and locations - INSTANCEID (defaults to 0 if not present)
Added support for another start location parameter after worldNum in UOX.INI representing instanceID (defaults to 0 if not present)
Updated TWEAK menu to include WorldNumber and instanceID
Fixed BaseWeight option in TWEAK menu
Updated CBase_Teleport - now takes an optional 5th parameter instanceID
Updated SE_SpawnNPC now takes an optional 5th parameter - instanceID
Updated SE_FindMulti now takes an optional 5th parameter - instanceID
Updated SE_GetItem now takes an optional 5th parameter - instanceID
Updated SE_FindItem now takes an optional 6th parameter - instanceID
Added new JS property for Items, Characters, Regions: .instanceID
Added JS property for Regions: .members - returns comma-separated list of town member serials
Updated JS scripts making use of the above-mentioned JS Methods/Functions
Updated dictionaries with new tweak menu entry texts
Exposed SpawnRegions to JS engine, and updated JS docs with details:
SpawnRegion JS Functions
IterateOverSpawnRegions()
GetSpawnRegion( spawnRegNum )
GetSpawnRegionCount()
SpawnRegion JS Properties
name
regionNum
itemList
npcList
item
npc
maxItems
maxNpcs
itemCount
npcCount
onlyOutside
prefZ
x1
y1
x2
y2
world
instanceID
minTime
maxTime
call
2020-08-08 13:57:15 +08:00
|
|
|
//| Purpose - Reload the dfn files.
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
//| Changes - 04042004 - Added the code to clear out the
|
2012-11-03 18:11:04 +00:00
|
|
|
//| Auto-AddMenu items so there isn't any duplication in the
|
|
|
|
|
//| multimap
|
2022-10-24 18:39:33 +08:00
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
auto CServerDefinitions::Reload() -> bool
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
// We need to clear out the AddMenuItem Map
|
|
|
|
|
g_mmapAddMenuMap.clear();
|
|
|
|
|
//
|
|
|
|
|
Cleanup();
|
2002-04-18 23:57:23 +00:00
|
|
|
ScriptListings.clear();
|
|
|
|
|
ScriptListings.resize( NUM_DEFS );
|
|
|
|
|
ReloadScriptObjects();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-29 09:34:51 +08:00
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - CServerDefinitions::Reload( DEFINITIONCATEGORIES toReload )
|
|
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Reload a specific set of dfn files.
|
|
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
auto CServerDefinitions::Reload( DEFINITIONCATEGORIES toReload ) -> bool
|
|
|
|
|
{
|
|
|
|
|
Dispose( toReload );
|
|
|
|
|
LoadDFNCategory( toReload );
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//==================================================================================================
|
|
|
|
|
auto CServerDefinitions::Cleanup() -> void
|
|
|
|
|
{
|
|
|
|
|
std::vector<VECSCRIPTLIST>::iterator slIter;
|
|
|
|
|
for( slIter = ScriptListings.begin(); slIter != ScriptListings.end(); ++slIter )
|
|
|
|
|
{
|
|
|
|
|
VECSCRIPTLIST& toDel = ( *slIter );
|
|
|
|
|
for( size_t j = 0; j < toDel.size(); ++j )
|
|
|
|
|
{
|
|
|
|
|
if( toDel[j] )
|
|
|
|
|
{
|
2022-06-14 11:36:04 -04:00
|
|
|
delete toDel[j];
|
|
|
|
|
toDel[j] = nullptr;
|
|
|
|
|
}
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//==================================================================================================
|
|
|
|
|
CServerDefinitions::~CServerDefinitions()
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
Cleanup();
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//==================================================================================================
|
|
|
|
|
auto CServerDefinitions::Dispose( DEFINITIONCATEGORIES toDispose ) -> bool
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
bool retVal = false;
|
2022-10-24 18:39:33 +08:00
|
|
|
if( toDispose != NUM_DEFS )
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
VECSCRIPTLIST& toDel = ScriptListings[toDispose];
|
2022-10-24 18:39:33 +08:00
|
|
|
for( VECSCRIPTLIST_CITERATOR dIter = toDel.begin(); dIter != toDel.end(); ++dIter )
|
|
|
|
|
{
|
|
|
|
|
Script *toDelete = ( *dIter );
|
|
|
|
|
if( toDelete )
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
retVal = true;
|
|
|
|
|
delete toDelete;
|
|
|
|
|
}
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
toDel.clear();
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
return retVal;
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - CServerDefinitions::FindEntry
|
|
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Find a specific CScriptSection from the DFNs in memory
|
|
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
auto CServerDefinitions::FindEntry( const std::string &toFind, DEFINITIONCATEGORIES typeToFind ) ->CScriptSection *
|
|
|
|
|
{
|
|
|
|
|
CScriptSection *rValue = nullptr;
|
2012-11-03 18:11:04 +00:00
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
if( !toFind.empty() && typeToFind != NUM_DEFS )
|
|
|
|
|
{
|
2022-03-04 07:35:46 -05:00
|
|
|
auto tUFind = oldstrutil::upper( toFind );
|
2012-11-03 18:11:04 +00:00
|
|
|
|
|
|
|
|
VECSCRIPTLIST& toDel = ScriptListings[typeToFind];
|
2022-10-24 18:39:33 +08:00
|
|
|
for( VECSCRIPTLIST_CITERATOR dIter = toDel.begin(); dIter != toDel.end(); ++dIter )
|
|
|
|
|
{
|
|
|
|
|
Script *toCheck = ( *dIter );
|
|
|
|
|
if( toCheck )
|
|
|
|
|
{
|
|
|
|
|
rValue = toCheck->FindEntry( tUFind );
|
|
|
|
|
if( rValue )
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
break;
|
2022-06-14 11:36:04 -04:00
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
}
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
}
|
2022-10-24 18:39:33 +08:00
|
|
|
return rValue;
|
2012-11-03 18:11:04 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//==================================================================================================
|
|
|
|
|
auto CServerDefinitions::FindEntrySubStr( const std::string &toFind, DEFINITIONCATEGORIES typeToFind ) ->CScriptSection *
|
|
|
|
|
{
|
|
|
|
|
CScriptSection *rValue = nullptr;
|
|
|
|
|
if( !toFind.empty() && typeToFind != NUM_DEFS )
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
VECSCRIPTLIST& toDel = ScriptListings[typeToFind];
|
2022-10-24 18:39:33 +08:00
|
|
|
for( VECSCRIPTLIST_CITERATOR dIter = toDel.begin(); dIter != toDel.end(); ++dIter )
|
|
|
|
|
{
|
|
|
|
|
Script *toCheck = ( *dIter );
|
|
|
|
|
if( toCheck )
|
|
|
|
|
{
|
|
|
|
|
rValue = toCheck->FindEntrySubStr( toFind );
|
|
|
|
|
if( rValue )
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
break;
|
2022-06-14 11:36:04 -04:00
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-10-24 18:39:33 +08:00
|
|
|
return rValue;
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
2020-08-14 08:58:15 +08:00
|
|
|
const std::string defExt = ".dfn";
|
2002-04-07 20:53:41 +00:00
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//==================================================================================================
|
|
|
|
|
struct PrioScan_st
|
|
|
|
|
{
|
2003-01-13 15:58:29 +00:00
|
|
|
std::string filename;
|
2002-04-07 20:53:41 +00:00
|
|
|
SI16 priority;
|
2022-10-24 18:39:33 +08:00
|
|
|
PrioScan_st() : filename( "" ), priority( 0 )
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
}
|
2022-10-24 18:39:33 +08:00
|
|
|
PrioScan_st( const char *toUse, SI16 mPrio ) : filename( toUse ), priority( mPrio )
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
}
|
2002-04-07 20:53:41 +00:00
|
|
|
};
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//==================================================================================================
|
|
|
|
|
inline auto operator == ( const PrioScan_st& x, const PrioScan_st& y ) -> bool
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
return ( x.priority == y.priority );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//==================================================================================================
|
|
|
|
|
inline auto operator < ( const PrioScan_st& x, const PrioScan_st& y ) -> bool
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
return ( x.priority < y.priority );
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//==================================================================================================
|
|
|
|
|
inline auto operator > ( const PrioScan_st& x, const PrioScan_st& y ) -> bool
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
return ( x.priority > y.priority );
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - CServerDefinitions::LoadDFNCategory
|
|
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Load the files found for each DFN category
|
|
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
auto CServerDefinitions::LoadDFNCategory( DEFINITIONCATEGORIES toLoad) -> void
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
CleanPriorityMap();
|
|
|
|
|
defaultPriority = 0;
|
|
|
|
|
UI08 wasPriod = 2;
|
|
|
|
|
BuildPriorityMap( toLoad, wasPriod );
|
2002-04-07 20:53:41 +00:00
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
CDirectoryListing fileList( toLoad, defExt );
|
2012-11-03 18:11:04 +00:00
|
|
|
fileList.Flatten( true );
|
2022-10-24 18:39:33 +08:00
|
|
|
std::vector<std::string> *shortListing = fileList.FlattenedShortList();
|
|
|
|
|
std::vector<std::string> *longListing = fileList.FlattenedList();
|
2012-11-03 18:11:04 +00:00
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
std::vector<PrioScan_st> mSort;
|
|
|
|
|
for( size_t i = 0; i < shortListing->size(); ++i )
|
|
|
|
|
{
|
|
|
|
|
mSort.push_back( PrioScan_st(( *longListing )[i].c_str(), GetPriority(( *shortListing )[i].c_str() )));
|
2012-11-03 18:11:04 +00:00
|
|
|
}
|
2022-10-24 18:39:33 +08:00
|
|
|
if( !mSort.empty() )
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
std::sort( mSort.begin(), mSort.end() );
|
2022-10-24 18:39:33 +08:00
|
|
|
Console.Print( oldstrutil::format( "Section %20s : %6i", dirNames[toLoad].c_str(), 0 ));
|
2012-11-03 18:11:04 +00:00
|
|
|
size_t iTotal = 0;
|
|
|
|
|
Console.TurnYellow();
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
std::vector<PrioScan_st>::const_iterator mIter;
|
|
|
|
|
for( mIter = mSort.begin(); mIter != mSort.end(); ++mIter )
|
|
|
|
|
{
|
|
|
|
|
Console.Print( "\b\b\b\b\b\b" );
|
|
|
|
|
ScriptListings[toLoad].push_back( new Script(( *mIter ).filename, toLoad, false ));
|
2012-11-03 18:11:04 +00:00
|
|
|
iTotal += ScriptListings[toLoad].back()->NumEntries();
|
2022-10-24 18:39:33 +08:00
|
|
|
Console.Print( oldstrutil::format( "%6i", iTotal ));
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
Console.Print( oldstrutil::format( "\b\b\b\b\b\b%6i", CountOfEntries( toLoad )));
|
2012-11-03 18:11:04 +00:00
|
|
|
Console.TurnNormal();
|
2022-10-24 18:39:33 +08:00
|
|
|
Console.Print( " entries" );
|
|
|
|
|
switch( wasPriod )
|
|
|
|
|
{
|
2022-06-14 11:36:04 -04:00
|
|
|
case 0:
|
2022-10-24 18:39:33 +08:00
|
|
|
Console.PrintSpecial( CGREEN, "prioritized" );
|
2022-06-14 11:36:04 -04:00
|
|
|
break; // prioritized
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
case 1:
|
2022-10-24 18:39:33 +08:00
|
|
|
Console.PrintSpecial( CGREEN, "done" );
|
2012-11-03 18:11:04 +00:00
|
|
|
break; // file exist, no section
|
2002-04-07 20:53:41 +00:00
|
|
|
default:
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
case 2:
|
2022-10-24 18:39:33 +08:00
|
|
|
Console.PrintSpecial( CBLUE, "done" );
|
2012-11-03 18:11:04 +00:00
|
|
|
break; // no file
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - CServerDefinitions::ReloadScriptObjects()
|
|
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Reload all the various categories of DFN scripts
|
|
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
auto CServerDefinitions::ReloadScriptObjects() -> void
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
Console << myendl;
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
for( SI32 sCtr = 0; sCtr < NUM_DEFS; ++sCtr )
|
|
|
|
|
{
|
|
|
|
|
LoadDFNCategory( static_cast<DEFINITIONCATEGORIES>( sCtr ));
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
CleanPriorityMap();
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//==================================================================================================
|
|
|
|
|
auto CServerDefinitions::CountOfEntries( DEFINITIONCATEGORIES typeToFind ) -> size_t
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
size_t sumEntries = 0;
|
2022-10-24 18:39:33 +08:00
|
|
|
VECSCRIPTLIST *toScan = &( ScriptListings[typeToFind] );
|
|
|
|
|
if( toScan )
|
|
|
|
|
{
|
|
|
|
|
for( auto cIter = toScan->begin(); cIter != toScan->end(); ++cIter )
|
|
|
|
|
{
|
2022-06-14 11:36:04 -04:00
|
|
|
sumEntries += (*cIter)->NumEntries();
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-04-07 20:53:41 +00:00
|
|
|
return sumEntries;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//==================================================================================================
|
|
|
|
|
auto CServerDefinitions::CountOfFiles( DEFINITIONCATEGORIES typeToFind ) -> size_t
|
|
|
|
|
{
|
2002-04-07 20:53:41 +00:00
|
|
|
return ScriptListings[typeToFind].size();
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//==================================================================================================
|
|
|
|
|
auto CServerDefinitions::FirstScript( DEFINITIONCATEGORIES typeToFind ) -> Script *
|
|
|
|
|
{
|
2021-06-12 07:30:23 -04:00
|
|
|
Script *retScript = nullptr;
|
2012-11-03 18:11:04 +00:00
|
|
|
slIter = ScriptListings[typeToFind].begin();
|
2022-10-24 18:39:33 +08:00
|
|
|
if( !FinishedScripts( typeToFind ))
|
|
|
|
|
{
|
|
|
|
|
retScript = ( *slIter );
|
2022-06-14 11:36:04 -04:00
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
return retScript;
|
|
|
|
|
}
|
2022-10-24 18:39:33 +08:00
|
|
|
//==================================================================================================
|
|
|
|
|
auto CServerDefinitions::NextScript( DEFINITIONCATEGORIES typeToFind ) ->Script *
|
|
|
|
|
{
|
2021-06-12 07:30:23 -04:00
|
|
|
Script *retScript = nullptr;
|
2022-10-24 18:39:33 +08:00
|
|
|
if( !FinishedScripts( typeToFind ))
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
++slIter;
|
2022-10-24 18:39:33 +08:00
|
|
|
if( !FinishedScripts( typeToFind ))
|
|
|
|
|
{
|
|
|
|
|
retScript = ( *slIter );
|
2022-06-14 11:36:04 -04:00
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
}
|
|
|
|
|
return retScript;
|
|
|
|
|
}
|
2022-10-24 18:39:33 +08:00
|
|
|
//==================================================================================================
|
|
|
|
|
auto CServerDefinitions::FinishedScripts( DEFINITIONCATEGORIES typeToFind ) -> bool
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
return ( slIter == ScriptListings[typeToFind].end() );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//==================================================================================================
|
|
|
|
|
auto CServerDefinitions::CleanPriorityMap() -> void
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
priorityMap.clear();
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
2022-10-24 18:39:33 +08:00
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - CServerDefinitions::BuildPriorityMap()
|
|
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Build DFN priority map based on entires from priority.nfo
|
|
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
auto CServerDefinitions::BuildPriorityMap( DEFINITIONCATEGORIES category, UI08& wasPrioritized ) -> void
|
|
|
|
|
{
|
|
|
|
|
CDirectoryListing priorityFile( category, "priority.nfo", false );
|
|
|
|
|
std::vector<std::string> *longList = priorityFile.List();
|
|
|
|
|
if( !longList->empty() )
|
|
|
|
|
{
|
|
|
|
|
std::string filename = ( *longList )[0];
|
2003-03-04 14:55:47 +00:00
|
|
|
// Do we have any priority informat?
|
2022-10-24 18:39:33 +08:00
|
|
|
if( FileExists( filename )) // the file exists, so perhaps we do
|
|
|
|
|
{
|
2022-06-09 08:02:49 -04:00
|
|
|
auto prio = std::make_unique<Script>( filename, category, false ); // generate a script for it
|
2022-10-24 18:39:33 +08:00
|
|
|
if( prio ) // successfully made a script
|
|
|
|
|
{
|
2022-06-09 08:02:49 -04:00
|
|
|
auto prioInfo = prio->FindEntry( "PRIORITY" ); // find the priority entry
|
2022-10-24 18:39:33 +08:00
|
|
|
if( prioInfo )
|
|
|
|
|
{
|
|
|
|
|
for( const auto &sec : prioInfo->collection() )
|
|
|
|
|
{
|
|
|
|
|
auto tag = sec->tag;
|
|
|
|
|
auto data = sec->data;
|
|
|
|
|
if( oldstrutil::upper( tag ) == "DEFAULTPRIORITY" )
|
|
|
|
|
{
|
|
|
|
|
defaultPriority = static_cast<UI16>( std::stoul( data, nullptr, 0 ));
|
More string handling modernization, and a minor fix
Increased default timer for worldsaves from 5 to 10 minutes
Fixed an issue where the tile command could spawn items with incorrect ID because tempInt2 wasn't reset properly
Additional string handling modernization in cAccountClass.cpp, cHTMLSystem.cpp, CResponse.cpp, cServerData.cpp, cServerData.h, cServerDefinitions.cpp, cSocket.cpp, cSpawnRegion.cpp, cSpawnRegion.h, cWeather.cpp, Dictionary.cpp, effect.cpp and uox3.cpp (punt)
2021-04-26 18:26:39 +08:00
|
|
|
}
|
2022-10-24 18:39:33 +08:00
|
|
|
else
|
|
|
|
|
{
|
2022-03-04 07:35:46 -05:00
|
|
|
std::string filenametemp = oldstrutil::lower( tag );
|
2022-10-24 18:39:33 +08:00
|
|
|
priorityMap[filenametemp] =static_cast<SI16>( std::stoi( data, nullptr, 0 ));
|
2003-03-04 14:55:47 +00:00
|
|
|
}
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
2003-03-04 14:55:47 +00:00
|
|
|
wasPrioritized = 0;
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
2022-10-24 18:39:33 +08:00
|
|
|
else
|
|
|
|
|
{
|
2003-03-04 14:55:47 +00:00
|
|
|
wasPrioritized = 1;
|
2022-06-09 08:02:49 -04:00
|
|
|
}
|
2021-06-12 07:30:23 -04:00
|
|
|
prio = nullptr;
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
2022-10-24 18:39:33 +08:00
|
|
|
else
|
|
|
|
|
{
|
2003-03-04 14:55:47 +00:00
|
|
|
wasPrioritized = 2;
|
2022-06-09 08:02:49 -04:00
|
|
|
}
|
2003-03-04 14:55:47 +00:00
|
|
|
return;
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
#if defined( UOX_DEBUG_MODE )
|
2022-10-24 18:39:33 +08:00
|
|
|
// Console.Warning( oldstrutil::format( "Failed to open priority.nfo for reading in %s DFN", dirNames[category].c_str() ));
|
2002-04-07 20:53:41 +00:00
|
|
|
#endif
|
2003-03-04 14:55:47 +00:00
|
|
|
wasPrioritized = 2;
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - CServerDefinitions::DisplayPriorityMap()
|
|
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Dump DFN priority map to console
|
|
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
void CServerDefinitions::DisplayPriorityMap()
|
|
|
|
|
{
|
2002-04-07 20:53:41 +00:00
|
|
|
Console << "Dumping map... " << myendl;
|
2022-10-24 18:39:33 +08:00
|
|
|
for( auto &[name, priority] : priorityMap )
|
|
|
|
|
{
|
2022-06-14 11:36:04 -04:00
|
|
|
Console << name << " : " << priority << myendl;
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
Console << "Dumped" << myendl;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//==================================================================================================
|
2022-10-24 23:42:16 +08:00
|
|
|
auto CServerDefinitions::GetPriority( const char *file ) -> SI16
|
2022-10-24 18:39:33 +08:00
|
|
|
{
|
2022-06-14 11:36:04 -04:00
|
|
|
auto retVal = defaultPriority;
|
2022-10-24 18:39:33 +08:00
|
|
|
auto lowername = oldstrutil::lower( file );
|
2022-06-14 11:36:04 -04:00
|
|
|
auto p = priorityMap.find( lowername );
|
2022-10-24 18:39:33 +08:00
|
|
|
if( p != priorityMap.end() )
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
retVal = p->second;
|
2022-06-14 11:36:04 -04:00
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
return retVal;
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//==================================================================================================
|
|
|
|
|
auto CDirectoryListing::PushDir( DEFINITIONCATEGORIES toMove ) -> bool
|
|
|
|
|
{
|
2022-06-14 11:36:04 -04:00
|
|
|
auto filePath = cwmWorldState->ServerData()->Directory( CSDDP_DEFS );
|
2022-10-24 18:39:33 +08:00
|
|
|
filePath += dirNames[toMove];
|
|
|
|
|
return PushDir( filePath );
|
2003-03-04 14:55:47 +00:00
|
|
|
}
|
2022-10-24 18:39:33 +08:00
|
|
|
//==================================================================================================
|
|
|
|
|
auto CDirectoryListing::PushDir( std::string toMove ) -> bool
|
|
|
|
|
{
|
2003-03-04 14:55:47 +00:00
|
|
|
std::string cwd = CurrentWorkingDir();
|
|
|
|
|
dirs.push( cwd );
|
2020-08-14 08:58:15 +08:00
|
|
|
auto path = std::filesystem::path( toMove );
|
2022-10-24 18:39:33 +08:00
|
|
|
auto rValue = true;
|
|
|
|
|
if( !std::filesystem::exists( path ))
|
|
|
|
|
{
|
|
|
|
|
Console.Error( oldstrutil::format( "DFN directory %s does not exist", toMove.c_str() ));
|
2003-03-04 14:55:47 +00:00
|
|
|
Shutdown( FATAL_UOX3_DIR_NOT_FOUND );
|
|
|
|
|
}
|
2022-06-14 11:36:04 -04:00
|
|
|
std::filesystem::current_path( path );
|
|
|
|
|
currentDir = toMove;
|
2022-10-24 18:39:33 +08:00
|
|
|
toMove = oldstrutil::replaceSlash( toMove );
|
|
|
|
|
shortCurrentDir = ShortDirectory( toMove );
|
|
|
|
|
return rValue;
|
|
|
|
|
}
|
|
|
|
|
//==================================================================================================
|
|
|
|
|
auto CDirectoryListing::PopDir() -> void
|
|
|
|
|
{
|
|
|
|
|
if( dirs.empty() )
|
|
|
|
|
{
|
|
|
|
|
Console.Error( "cServerDefinition::PopDir called, but dirs is empty" );
|
2003-03-04 14:55:47 +00:00
|
|
|
Shutdown( FATAL_UOX3_DIR_NOT_FOUND );
|
2003-01-13 15:58:29 +00:00
|
|
|
}
|
2022-10-24 18:39:33 +08:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
auto path = std::filesystem::path( dirs.top() );
|
2020-08-14 08:58:15 +08:00
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
if( std::filesystem::exists( path ))
|
|
|
|
|
{
|
|
|
|
|
std::filesystem::current_path( path );
|
2020-08-14 08:58:15 +08:00
|
|
|
}
|
2003-03-04 14:55:47 +00:00
|
|
|
dirs.pop();
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-10-24 18:39:33 +08:00
|
|
|
//==================================================================================================
|
|
|
|
|
CDirectoryListing::CDirectoryListing( bool recurse ) : extension( ".dfn" ), doRecursion( recurse )
|
|
|
|
|
{
|
2003-03-04 14:55:47 +00:00
|
|
|
}
|
2022-10-24 18:39:33 +08:00
|
|
|
//==================================================================================================
|
|
|
|
|
CDirectoryListing::CDirectoryListing( const std::string &dir, const std::string &extent, bool recurse ) : doRecursion( recurse )
|
|
|
|
|
{
|
2003-03-04 14:55:47 +00:00
|
|
|
Extension( extent );
|
|
|
|
|
Retrieve( dir );
|
|
|
|
|
}
|
2022-10-24 18:39:33 +08:00
|
|
|
//==================================================================================================
|
|
|
|
|
CDirectoryListing::CDirectoryListing( DEFINITIONCATEGORIES dir, const std::string &extent, bool recurse ) : doRecursion( recurse )
|
|
|
|
|
{
|
|
|
|
|
Extension( extent );
|
|
|
|
|
Retrieve( dir );
|
2003-03-04 14:55:47 +00:00
|
|
|
}
|
2022-10-24 18:39:33 +08:00
|
|
|
//==================================================================================================
|
|
|
|
|
CDirectoryListing::~CDirectoryListing()
|
|
|
|
|
{
|
|
|
|
|
while( !dirs.empty() )
|
|
|
|
|
{
|
2020-08-14 08:58:15 +08:00
|
|
|
auto path = std::filesystem::path( dirs.top() );
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
if( std::filesystem::exists( path ))
|
|
|
|
|
{
|
2020-08-14 08:58:15 +08:00
|
|
|
std::filesystem::current_path( path );
|
|
|
|
|
}
|
2003-03-04 14:55:47 +00:00
|
|
|
dirs.pop();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//==================================================================================================
|
|
|
|
|
auto CDirectoryListing::Retrieve( const std::string &dir ) -> void
|
|
|
|
|
{
|
2003-03-04 14:55:47 +00:00
|
|
|
bool dirSet = PushDir( dir );
|
|
|
|
|
InternalRetrieve();
|
2022-10-24 18:39:33 +08:00
|
|
|
if( dirSet )
|
|
|
|
|
{
|
2003-03-04 14:55:47 +00:00
|
|
|
PopDir();
|
2022-06-14 11:36:04 -04:00
|
|
|
}
|
2003-03-04 14:55:47 +00:00
|
|
|
}
|
2022-10-24 18:39:33 +08:00
|
|
|
//==================================================================================================
|
|
|
|
|
auto CDirectoryListing::Retrieve( DEFINITIONCATEGORIES dir ) -> void
|
|
|
|
|
{
|
|
|
|
|
bool dirSet = PushDir( dir );
|
2003-03-04 14:55:47 +00:00
|
|
|
InternalRetrieve();
|
2022-10-24 18:39:33 +08:00
|
|
|
if( dirSet )
|
|
|
|
|
{
|
2003-03-04 14:55:47 +00:00
|
|
|
PopDir();
|
2022-06-14 11:36:04 -04:00
|
|
|
}
|
2003-03-04 14:55:47 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//==================================================================================================
|
|
|
|
|
auto CDirectoryListing::List() -> std::vector<std::string>*
|
|
|
|
|
{
|
2003-03-04 14:55:47 +00:00
|
|
|
return &filenameList;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//==================================================================================================
|
|
|
|
|
auto CDirectoryListing::ShortList() -> std::vector<std::string>*
|
|
|
|
|
{
|
2003-03-04 14:55:47 +00:00
|
|
|
return &shortList;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//==================================================================================================
|
|
|
|
|
auto CDirectoryListing::FlattenedList() -> std::vector<std::string>*
|
|
|
|
|
{
|
2003-03-04 14:55:47 +00:00
|
|
|
return &flattenedFull;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//==================================================================================================
|
|
|
|
|
auto CDirectoryListing::FlattenedShortList() -> std::vector<std::string>*
|
|
|
|
|
{
|
2003-03-04 14:55:47 +00:00
|
|
|
return &flattenedShort;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - CDirectoryListing::InternalRetrieve()
|
|
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - ???
|
|
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
auto CDirectoryListing::InternalRetrieve() -> void
|
|
|
|
|
{
|
2020-08-14 08:58:15 +08:00
|
|
|
std::string filePath;
|
|
|
|
|
auto path = std::filesystem::current_path();
|
2022-10-24 18:39:33 +08:00
|
|
|
for( const auto& entry : std::filesystem::directory_iterator( path ))
|
|
|
|
|
{
|
2020-08-14 08:58:15 +08:00
|
|
|
auto name = entry.path().filename().string();
|
|
|
|
|
filePath = entry.path().string();
|
|
|
|
|
auto ext = entry.path().extension();
|
2022-10-24 18:39:33 +08:00
|
|
|
if( std::filesystem::is_regular_file( entry ))
|
|
|
|
|
{
|
|
|
|
|
if( !extension.empty() )
|
|
|
|
|
{
|
|
|
|
|
if( entry.path().extension().string() != extension )
|
|
|
|
|
{
|
2020-08-14 08:58:15 +08:00
|
|
|
name = "";
|
2020-08-26 21:55:51 +08:00
|
|
|
}
|
|
|
|
|
}
|
2022-10-24 18:39:33 +08:00
|
|
|
if( !name.empty() )
|
|
|
|
|
{
|
2020-08-14 08:58:15 +08:00
|
|
|
shortList.push_back( name );
|
|
|
|
|
filenameList.push_back( filePath );
|
2003-03-04 14:55:47 +00:00
|
|
|
}
|
|
|
|
|
}
|
2022-10-24 18:39:33 +08:00
|
|
|
else if( std::filesystem::is_directory( entry ) && doRecursion )
|
|
|
|
|
{
|
|
|
|
|
subdirectories.push_back( CDirectoryListing( name, extension, doRecursion ));
|
2003-03-04 14:55:47 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//==================================================================================================
|
|
|
|
|
auto CDirectoryListing::Extension( const std::string &extent ) -> void
|
|
|
|
|
{
|
2003-03-04 14:55:47 +00:00
|
|
|
extension = extent;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - CDirectoryListing::Flatten()
|
|
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Flatten list of filenames
|
|
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
auto CDirectoryListing::Flatten( bool isParent ) -> void
|
|
|
|
|
{
|
2003-03-04 14:55:47 +00:00
|
|
|
ClearFlatten();
|
2022-10-24 18:39:33 +08:00
|
|
|
std::for_each( filenameList.begin(), filenameList.end(), [isParent, this]( const std::string & entry )
|
|
|
|
|
{
|
|
|
|
|
flattenedFull.push_back( entry );
|
|
|
|
|
auto temp = std::string();
|
|
|
|
|
if( !isParent )
|
|
|
|
|
{
|
|
|
|
|
temp = shortCurrentDir + "/"s;
|
2003-03-04 14:55:47 +00:00
|
|
|
}
|
2022-10-24 18:39:33 +08:00
|
|
|
temp += entry;
|
|
|
|
|
flattenedShort.push_back( temp );
|
2022-06-06 11:27:53 -04:00
|
|
|
});
|
2022-10-24 18:39:33 +08:00
|
|
|
std::string temp;
|
2012-11-03 18:11:04 +00:00
|
|
|
DIRLIST_ITERATOR dIter;
|
|
|
|
|
for( dIter = subdirectories.begin(); dIter != subdirectories.end(); ++dIter )
|
2003-03-04 14:55:47 +00:00
|
|
|
{
|
2022-10-24 18:39:33 +08:00
|
|
|
( *dIter ).Flatten( false );
|
|
|
|
|
auto shortFlat = ( *dIter ).FlattenedShortList();
|
|
|
|
|
auto longFlat = ( *dIter ).FlattenedList();
|
2012-11-03 18:11:04 +00:00
|
|
|
for( size_t k = 0; k < longFlat->size(); ++k )
|
2003-03-04 14:55:47 +00:00
|
|
|
{
|
2022-10-24 18:39:33 +08:00
|
|
|
flattenedFull.push_back(( *longFlat )[k] );
|
2003-03-04 14:55:47 +00:00
|
|
|
if( isParent )
|
2022-10-24 18:39:33 +08:00
|
|
|
{
|
2003-03-04 14:55:47 +00:00
|
|
|
temp = "";
|
2022-10-24 18:39:33 +08:00
|
|
|
}
|
2003-03-04 14:55:47 +00:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
temp = shortCurrentDir;
|
|
|
|
|
temp += "/";
|
|
|
|
|
}
|
2022-10-24 18:39:33 +08:00
|
|
|
temp += ( *shortFlat )[k];
|
2003-03-04 14:55:47 +00:00
|
|
|
flattenedShort.push_back( temp );
|
|
|
|
|
}
|
2022-10-24 18:39:33 +08:00
|
|
|
( *dIter ).ClearFlatten();
|
2003-03-04 14:55:47 +00:00
|
|
|
}
|
|
|
|
|
}
|
2022-10-24 18:39:33 +08:00
|
|
|
|
|
|
|
|
//==================================================================================================
|
|
|
|
|
auto CDirectoryListing::ClearFlatten() -> void
|
|
|
|
|
{
|
2003-03-04 14:55:47 +00:00
|
|
|
flattenedFull.clear();
|
|
|
|
|
flattenedShort.clear();
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|