*`StreamReader.Read` methods now return errors
The other edits in this commit are related to cleaning up lint errors
caused by the changes to StreamReader
* logger for d2audio & d2map
* logger for d2ui e.t.c
* d2inventory now passes on error messages
* no more importing log in d2core
* implemented #925
* added logger to part of d2networking & fixed "need to be changed" comments
* fixed lints
* fixed errors
Co-authored-by: M. Sz <mszeptuch@protonmail.com>
* Remove d2config.Config singleton
* refactored config file bootstrap
* `d2loader.Loader` adds the config directories during init
* `d2asset.AssetManager` loads the config file during init
* mpq verification logic removed from d2config; this is done by d2loader
* added `errorMessage` to `d2app.App` for setting the error message for the error screen.
* fixed loader test
* refactored logging in d2config, d2record, and d2asset
* asset manager, record manager, and file loader now utilitize d2util.Logger
* added colored logging to d2util.Logger (excluding windows platforms)
* removed mpq file verification from d2config; d2loader handles this
* record loaders now use the record manager's logger for printing info
* added command line argument for setting log level (`--loglevel 4`, `-l4`, or `-l 4`
* added `LogLevel` parameter to config file
* default log level will show errors, warnings, and info log messages
* specifying log level as an argument overrides setting from config file
* fixed log level tests
* Move engine initialization to d2app
* adding debug print of error returned from `App.Run`
* adding ClampInt utility function to d2math
* cleaned up argument parsing in app.go, dedicated server no longer starts a renderer
Co-authored-by: gravestench <dknuth0101@gmail.com>
* removed the rest of the magic number errors from d2game
* hotfix for bug i added in map engine test
* removed TODO's from d2mapengine/engine.go, added link to github issue
* removed TODO's and made issues and other minor lint work
* lint cleanup, mostly removing TODO's and putting links to their issues on github
* adds error handling, returns early from funcs where it makes sense
* fixes build errors
* merge ballresin PR with upstream
* adds error handling, returns early from funcs where it makes sense
* fixes build errors
* merge ballresin PR with upstream
Co-authored-by: dknuth <dknuth0101@gmail.com>
* removing objects records from d2datadict
* removing Overlay singleton from d2datadict
* remove PetTypes singleton from d2datadict
* remove PlayerClass singleton from d2datadict
* removed PlrModes singleton from d2datadict
* removed Properties singleton from d2datadict
* removed ItemQuality singleton from d2datadict
* removed RarePrefix and RareSuffix singletons from d2datadict
* removed States singleton from d2datadict
* removed Runewords singleton from d2datadict
* removed Sets and SetItems singletons from d2datadict
* remoed Shrines singleton from d2datadict
* removed UniqueItems singleton from d2datadict
* removed SuperUniques singleton from d2datadict
* removed TreasureClass singleton from d2datadict
* removed UniqueAppellation singleton from d2datadict
* removed d2datadict
* removed data dict init from d2app, this has moved to asset manager init
* Remove weapons, armor, misc, itemCommon, itemTyps datadict singletons
- removed loader calls from d2app
- removed the HeroObjects singleton from `d2core/d2inventory`
- added an InventoryItemFactory in d2inventory
- package-level functions that use data records are now methods of the InventoryItemFactory
- renamed ItemGenerator in d2item to ItemFactory
- package-level functions that use records are now methods of ItemFactory
- d2map.MapEntityFactory now has an item factory instance for creating items
- fixed a bug in unique item record loader where it loaded an empty record
- added a PlayerStateFactory for creating a player state (uses the asset manager)
- updated the test inventory/equipment code in d2player to handle errors from the ItemFactory
- character select and character creation screens have a player state and inventory item factory
- updated item tests to use the item factory
* minor edit
* Removed d2datadict.Experience singleton
added a HeroStatsFactory, much like the other factories. The factory gets an
asset manager reference in order to use data records.
* removed d2datadict.AutoMagic singleton
* removed d2datadict.AutoMap singleton
* removed d2datadict.BodyLocations singleton
* removed d2datadict.Books singleton
* Removed singletons for level records
- removed loader calls in d2app
- changed type references from d2datadict to d2records
- added a `MapGenerator` in d2mapgen which uses thew asset manager and map engine
- package-level map generation functions are now MapGenerator methods
- `d2datadict.GetLevelDetails(id int)` is now a method of the RecordManager
* remove SkillCalc and MissileCalc singletons
* Removed CharStats and ItemStatCost singletons
- added an ItemStatFactory which uses the asset manager to create stats
- package-level functions for stats in d2item are now StatFactory methods
- changed type references from d2datadict to d2records
- `d2player.GetAllPlayerStates` is now a method of the `PlayerStateFactory`
* Removed DkillDesc and Skills singletons from d2datadict
- removed loader calls from d2app
- diablo2stats.Stat instances are given a reference to the factory for doing record lookups
* update the stats test to use mock a asset manager and stat factory
* fixed diablo2stats tests and diablo2item tests
* removed CompCodes singleton from d2datadict
* remove cubemain singleton from d2datadict
* removed DifficultyLevels singleton from d2datadict
* removed ElemTypes singleton from d2datadict
* removed events.go loader from d2datadict (was unused)
* removed Gems singleton from d2datadict
* removed Hireling and Inventory singletons from d2datadict
* removed MagicPrefix and MagicSuffix singletons from d2datadict
* removed ItemRatios singleton from d2datadict
* removed Missiles singleton from d2datadict
* removed MonModes singleton
* Removed all monster and npc singletons from d2datadict
- MapStamp instances now get a reference to their factory for doing record lookups
* removed SoundEntry and SoundEnviron singletons from d2datadict
* Prevent player movement and casting if current spell cast is not finished yet
* Properly format the fields of Player struct
Co-authored-by: Presiyan Ivanov <presiyan-ivanov@users.noreply.github.com>
* improve AssetManager implementation
Notable changes are:
* removed the individual managers inside of d2asset, only one asset manager
* AssetManager now has caches for the types of files it loads
* created a type for TextDictionary (the txt file structs)
* fixed a file path bug in d2loader Source
* fixed a asset stream bug in d2loader Asset
* d2loader.Loader now needs a d2config.Config on creation (for resolving locale files)
* updated the mpq file in d2asset test data, added test case for "sub-directory"
* added a Data method to d2asset.Asset. The data is cached on first full read.
* renamed ArchiveDataStream to DataStream in d2interface
* moved palette utility func out of d2asset and into d2util
* bugfix for MacOS mpq loader issue
* minor lint fixes
* removed obsolete interfaces from d2interface
* lint fixes, added data caching to filesystem asset
* adding comment for mpq asset close
* adding comment for mpq asset close
* export d2asset singleton
* add *d2asset.AssetManager to d2app
- d2app now has a reference to an asset manager which it will use for loading
- added asset loader methods to the asset manager
- functions in d2asset are now wrappers for asset manager methods
* add asset manager reference to audio provider
- d2app asset manager reference is now passed to audio provider
- asset manager is created in main.go for now to pass into audio provider
- CreateSoundEffect is now a method, no longer exported, uses the asset manager reference
* d2app passes asset manager refence to map engine test
* in d2asset, all calls to LoadFile replaced with call to Singleton.Loadfile
* blizzard intro and credits screen
- d2app passes reference to the asset manager to these screens
* asset manager for d2map
- adding MapStampFactory, takes an asset manager reference
- embedded MapStampFactory into the MapEngine
- LoadStamp is now a method of the MapStampFactory
* d2asset: removed LoadFileStream, LoadFile, and FileExists
* d2gui changes
- singleton now has an asset manager reference
- calls to d2asset loader functions removed
- createButton is now a method of LayoutManager
- moved LayoutEntry to its own file
* map entity factory
- Map engine has an embedded map entity factory
- Map stamp factory gets a reference to the map engine's entity factory
- Stamps are given a reference to the map engine entity factory when created
- Character select gets a map entity factory
- Embedded the stamp factory into the MapEngine
* asset manager for d2ui
- d2ui is passed an asset manager reference when created
- all calls to d2asset loader functions in d2ui now refer to the asset manager
- d2gamescreen gets a ui manager when created
- help overlay is now passed a ui manager when created
* d2gamescreen + d2player: asset manager references
added an asset manager reference to
- inventory panel + inventory grid
- mini panel
- game controls
- help overlay
- character select
- main menu
- select hero class
- hero stats panel
* Removed d2asset.LoadAnimation
all references to this function have been replaced with calls to the asset manager method
* adding asset to help overlay, bugfix for 4d59c91
* Removed d2asset.LoadFont and d2asset.LoadAnimationWithEffect
all references to these have been replaced with calls to the asset manager methods
* MapRenderer now gets an asset manager reference
* removed d2asset.LoadPalette
all references have been replaced with calls to an asset manager instance
* merged d2object with d2mapentity
d2object was only being used to create objects in the map, so the provider
function is now a method of the map entity factory. calls to d2asset have
been removed.
* removed d2asset.LoadComposite
all calls are now made to the asset manager method
* removed d2asset singleton
all singleton references have been removed, a single instance of the
asset manager is passed around the entire app
* rename Initialize to NewAssetManager
* move music path enumerations into d2resource
* move text dictionary (.tbl) loader into d2fileformats sub-package d2tbl
* lint fix, add doc file for d2tbl
* moved data_dictionary.go into d2fileformats sub-package d2txt, added doc file
* added sub-packages d2geom for geometry-related things, and d2path for path-related things
* moved calcstring.go to d2calculation
* move bitmuncher, bitstream, stream reader/writer from d2common into sub-package d2datautils
* fix lint errors in d2datadict loaders (caused by moving stuf around in d2common)
* move size.go into d2geom
* move d2common/cache.go into sub-package d2common/d2cache
* renamed d2debugutil to d2util, moved utility functions from d2common into d2util
* adding loaders for rare prefix/suffix records
* switch to slices instead of maps for storing rare prefix/suffix records
* rare items now use the rare prefix/suffix names
* fixed lint errors in button.go
* fixed lint errors in checkbox.go
* Removed d2ui singleton, fixed nearly all lint errors
- Changed `UI` struct to `UIManager`, removed singleton
- UI element provider functions are now methods of the UI Manager
- Screens now use the UI manager to create UI elements
- game panels in d2player now use the UI Manager to create UI elements
- Only the UI manager knows about "widgets"; calls to `d2ui.AddWidget` in Screen instances have been removed
* changed ui element provider methods from `Create` to `New`