Commit Graph

504 Commits

Author SHA1 Message Date
gravestench 87d531814d d2datautil.StreamReader refactor
*`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
2021-01-12 10:26:27 -08:00
gravestench 1fc787023d fixed lint errors 2021-01-11 01:31:57 -08:00
gravestench aa8525ff31 removed commented code 2021-01-11 01:16:29 -08:00
gravestench 2c0f3d9cd9 d2tbl.LoadTextDictionary now returns an error 2021-01-11 01:12:46 -08:00
Tim Sarbin c99810ad0e Fixed various bugs, crashes, and slowdowns. 2021-01-10 02:44:42 -05:00
Intyre db83814527
d2mpq refactored (#1020)
* d2mpq refactor

* d2mpq refactor last standing lint error

* d2mpq refactor: less linter noise

* d2mpq refactor: more linter issues
2021-01-08 12:46:11 -08:00
gucio321 6addf7a243
removed links to closed issues from code (#1005)
Co-authored-by: M. Sz <mszeptuch@protonmail.com>
Co-authored-by: gravestench <dknuth0101@gmail.com>
2021-01-06 21:48:12 -08:00
Tim Sarbin 92989d6d7a Removed improper ebiten dependency in d2interface. 2020-12-30 02:08:32 -05:00
Intyre 1e91df996c Refactor StreamReader 2020-12-23 10:43:33 +01:00
Intyre b78dca52c2 Refactor StreamWriter 2020-12-23 10:43:33 +01:00
Tim Sarbin b4f1e8cbbd
Merge pull request #1000 from gucio321/multi-language-support
ckecked value of italian modifier
2020-12-22 09:25:20 -05:00
M. Sz bc17f2c422 ckecked value of italian modifier 2020-12-22 10:45:30 +01:00
Tim Sarbin 0f658d5dec
Merge pull request #999 from Intyre/term
Cleaned up d2term
2020-12-21 20:21:20 -05:00
Intyre 04ec879035 Cleaned up d2term 2020-12-21 21:46:58 +01:00
M. Sz 0c04e9b3d5 skill select menu dependencies (when we open skillselect menu, other panels are closed) 2020-12-21 17:37:59 +01:00
Tim Sarbin c79c2a8c89
Merge pull request #983 from gucio321/quest-log-part2
Quest Log - quest completion animation
2020-12-17 11:35:25 -05:00
M. Sz be8b3e3157 stats changing: hero stats panel 2020-12-16 16:49:50 +01:00
M. Sz 08e590f3e4 quest animation initial. 2020-12-16 15:08:39 +01:00
gucio321 2e31f3d1ec
Move Gold Panel (#962)
* move gold panel
2020-12-12 01:39:26 -08:00
M. Sz dffa8ff865 moved max quests acts to d2enum 2020-12-04 10:43:33 +01:00
M. Sz ed89d91ae4 code cleanup 2020-12-04 09:20:38 +01:00
M. Sz 2c303d74f2 quest status init 2020-12-03 10:40:01 +01:00
M. Sz c7a841fe5a Merge branch 'hotfix' of https://github.com/gucio321/OpenDiablo2 into hotfix 2020-12-02 09:41:52 +01:00
gucio321 96916863ff
Quest log initial (#956)
* Adding character quest panel
2020-12-01 23:19:15 -08:00
M. Sz fa1e86acc3 added quest log items to d2resources and modified player movement speed 2020-11-29 17:08:46 +01:00
M. Sz b0af051f4c d2resource - escape menu labels 2020-11-28 19:58:22 +01:00
Tim Sarbin 73d381215e
Merge pull request #951 from gucio321/multi-language-labels
Multi language labels
2020-11-27 11:47:54 -05:00
M. Sz 640a9e043d code cleanup 2020-11-26 12:25:47 +01:00
M. Sz 1dcd63a238 fixed lint errors 2020-11-26 11:30:11 +01:00
M. Sz 76257ca351 moved some stuff 2020-11-26 11:13:35 +01:00
M. Sz 6f6516ae33 a bit updated comments 2020-11-25 20:57:52 +01:00
M. Sz 91f28516ff fixed lints 2020-11-25 19:25:19 +01:00
M. Sz 56787b13b8 Opimalisation 2020-11-25 12:37:16 +01:00
Thomas Christlieb 320583b5d4 save act and difficulty. Fixes #866 2020-11-25 11:51:20 +01:00
M. Sz d87e4a846a init of multi-language main menu 2020-11-25 10:03:50 +01:00
gucio321 33bc9fe434
locale strings for character select & hero stat panel (#948)
* character select screen's hero descriptions & hero stat panel

* cinematics names

* buttons on character select screen and "resistances" labels on hero stats panel

Co-authored-by: M. Sz <mszeptuch@protonmail.com>
2020-11-24 23:45:30 -08:00
M. Sz 0f2c5cecb1 fixed lints 2020-11-24 17:50:31 +01:00
M. Sz c704cc4c45 buttons on character select screen and "resistances" labels on hero stats panel 2020-11-24 17:44:15 +01:00
gucio321 2153f5ce64
implemented logger in d2gamescreen (#925)
* implemented logger in d2gamescreen

* logger in d2game/d2player

* logger for app.go
2020-11-18 13:02:49 -08:00
Michał Mrówka 2a36c956a4
Label fix (#931) 2020-11-17 23:50:31 -08:00
Michał Mrówka bbba67487d
Added support for charset 2020-11-16 21:39:48 +01:00
Michał Mrówka 5d5e10f229
Remove language option from config file 2020-11-16 12:47:11 +01:00
Julien Ganichot 0d691dbffa
Key binding menu (#918)
* Feat(KeyBindingMenu): Adds dynamic box system with scrollbar

* Feat(Hotkeys): WIP Adds a lot of things

* Feat(KeyBindingMenu): WIP Adds logic to binding

* Feat(KeyBindingMenu): Fixes assignment logic

* Feat(KeyBindingMenu): Adds buttons logic

* Feat(KeyBindingMenu): Fixes sprites positions+add padding to Box

* Feat(KeyBindingMenu): Adds label blinking cap

* Feat(KeyBindingMenu): Removes commented func

* Feat(KeyBindingMenu): Fixes lint errors and refactors a bit

* Feat(KeyBindingMenu): Corrects few minor things from Grave

* Feat(KeyBindingMenu): removes forgotten key to string mapping
2020-11-13 12:03:30 -08:00
M. Sz 2eda3827ce cinematics select background 2020-11-10 15:00:40 +01:00
M. Sz e20d544a8c Buttons in cinematics menu 2020-11-10 15:00:40 +01:00
M. Sz bd4cf1a334 cinematics menu init 2020-11-10 15:00:40 +01:00
Gürkan Kaymak e99fbf5c4b
showed an error message if the client cannot connect to a host (#910) 2020-11-08 14:03:51 -05:00
gravestench be9c29e9d2
Unfuck asset manager init (#906)
* moved loader bootstrap logic into d2app
2020-11-08 01:24:35 -08:00
gravestench f7fb35a4ec
removed debug printer singleton from d2util (#901)
resolves #504
2020-11-03 11:19:59 -08:00
gravestench af1f0a0eda
removed string table singleton from d2common/d2fileformats/d2tbl/ (#900) 2020-11-03 11:10:11 -08:00
gravestench 5ac03d6f49
refactored game bootstrap, removed `d2config.Config` singleton (#899)
* 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
2020-11-03 07:54:15 -05:00
gravestench d6c9748fef
refactored logging in d2loader, d2record, and d2asset (#898)
* 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
2020-11-02 21:23:07 -05:00
gravestench b052006922
add comment explaining significance of input handler return value (#895) 2020-11-02 01:14:03 -08:00
Julien Ganichot 8365400ff5
Feat(KeyMapping): Adds a configurable keymap to GameControls, resolves #793 (#893)
* Feat(KeyMapping): Adds a configurable keymap to GameControls + Updates help overlay to use it

Co-authored-by: gravestench <dknuth0101@gmail.com>
2020-11-01 19:43:23 -08:00
Julien Ganichot 1f2771e8bc
Resolves #874 and #892 (#894)
* 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>
2020-11-01 16:05:50 -08:00
Tim Sarbin 1a6c6b8e9f
Add panic screen (#878)
* Add panic screen

* Fixed lint error. Updated all module references
2020-10-28 21:02:12 -04:00
gravestench 6e31cfb52a
migrate to ebiten v2.0 API (#860)
* migrate to ebiten v2.0 API

* fixed lint errors
2020-10-28 14:17:42 -04:00
gravestench 4a62101b96
adding the rest of the data dictionary loaders (#869) 2020-10-28 13:52:15 -04:00
Gürkan Kaymak ec9c0c3d95
fixes #767, implemented deepCopy for the dcc_animation and dc6_animation (#852) 2020-10-26 09:13:08 -04:00
gravestench dd0c148784
fixed all `gocognit` lint errors (#848)
* reduced ItemFactory.NewItem complexity

* d2compression/wav.go: suppressing gocognit lint error, suppressing gocyclo lint error

* d2maprenderer/renderer.go: reducing complexity of rnderPass2 and renderPass3
2020-10-26 03:53:42 -07:00
gravestench aa9f6be411
Lint cleanup gocyclo (#847)
* d2player/inventory.go: fixed gocyclo error, broke up render method to smaller methods

* d2client/game_client.go: suppressing gocyclo error for OnPacketReceived, doesnt make sense to split

* d2remoteclient/remote_client_connection.go: suppressing gocyclo error for decodeToPacket, doesnt make sense to split

* d2dcc/dcc_direction.go: suppressing gocyclo error in generateFrames
2020-10-26 02:24:04 -07:00
gravestench 6f8b43f8d6
Various lint error fixes and suppressions (#846)
* suppressing the magic number lint errors in mapgen, it will get a heavy refactor soon, hopefully...

* adding string token constants for SkillClass

* adding panic on error to left/right skill select render

* fixed cuddle lint error

* fixed unnecessary conversion, unused func param lint errors in dcc_animation.go

* adding comment for skill class tokens

* fixed typo in comment

* removed unused parameter in dcc/dc6 animations

* supress warning about Object.setMode always being passed direction value of 0

* fixed all invalid golint directives

* fixed a couple gocritic lint errors
2020-10-26 02:04:50 -07:00
gravestench 622186e350
fixed 'dupl' lint errors (#845)
* removed dupl lint errors in d2compression/huffman.go

* remove duplicate code for set/unique item properties

This is a more involved edit. I've added a `PropertyDescriptor`
which is a common struct that should have existed already. The
`PropertyDescriptor` is used to generate property instances, and is common
to item affixes, set items, sets, unique items, and runewords.

This was all to remove duplicate code in d2item/

* removed duplicate code for rare item affixes
2020-10-26 00:38:18 -07:00
gravestench 815cfa09cb
fix all gosec lint errors (#844) 2020-10-25 23:38:15 -07:00
gravestench 02acba231b
removed all 'wsl' lint errors (#836) 2020-10-25 17:28:40 -07:00
gravestench 1ce2af19bf
removed all 'gocritic' lint errors (#835) 2020-10-25 17:03:23 -07:00
gravestench a1380bc264
removed all `golint` lint errors (#833)
* removed all 'golint' type lint errors
2020-10-25 16:23:55 -07:00
gravestench 025ee94e50
Removed all TODO's in project (#831)
* removed the rest of the magic number errors from d2game

* hotfix for bug i added in map engine test

* removed all TODO's in project, made issues on github for each one
2020-10-25 18:36:12 -04:00
gravestench 589850a728
Removing TODO comments, making issues for them (#807)
* 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
2020-10-25 10:21:14 -04:00
presiyan-ivanov 7661b81576
Initial left & right skill select panel implementation. HeroSkill serialization cleanup. (#783)
- Clicking the active left/right skill now opens a skill select panel.
Only the available skills for the hero, which are valid for the panel type are shown.
Clicking on a skill from the skill select panel makes it the new active skill for the hero.

- Hovering a skill in the skill select panel shows the skill name +
skill description.

- New command which learns all skills for a specific
class(not persisted to a save file yet) - e.g. `learnskills ama` will learn
skills for the Amazon class.

- Initialize HeroSkill.shallowHeroSkill struct in the hero state factory, so we can use it
when we serialize the HeroSkill to packets/game save files.

- The parsed Skill.ListRow is now a number instead  of string.

Co-authored-by: Presiyan Ivanov <presiyan-ivanov@users.noreply.github.com>
2020-10-22 16:53:18 -04:00
juander-ux e5dae4e5d8
Inital skilltree panel implementation (#782)
* d2ui/UIFrame: Refactor into its own class

it's not useful to have the handling of frames for the
inventory/herostate/skilltree/quest panels individually in each of
those.

* d2ui/button: Fix crash when a buttonlayout was not allowing FrameChange

When AllowFrameChange is false we do not create pressedSurface. So if we
press the button the game will crash.

* d2ui/button: Allow label-only buttons

At least for the skillmenu we need buttons were the graphic size does
not match the buttonsize. So let's render the graphic in there and make
the button label only.

* d2hero/hero_state_factory: Give all heroes their class specific skills

* d2player/gamecontrols: Fix wrong inventory/stats layouts for exp chars

For Druid/Assassin the inventory frame was rendered for a 640x480
resolution. This brings it in line with all other characters.

* d2player: Add inital Skilltree panel

* d2player/game_controls: Enable skilltree

Note here, that the inventory panel and skilltree panel can overlap.

* d2player/skilltree: Add skillicon rendering

Note here, that I couldn't figure out how to render them dark if no
skillpoints are invested.

Signed-off-by: juander <juander@rumtueddeln.de>
2020-10-22 12:54:45 -04:00
gravestench e274260787
fixed all golint type lint errors (#780) 2020-10-21 23:41:21 -07:00
gravestench 783993470e
Lint error cleanup1 (#779)
* fixed lint error in d2app/app.go

* go fmt entire project

* adding doc.go for d2records

* fixed lint issues in d2core/d2map

* fixed lint error in d2interface/palette.go

* fixed lint error in  d2core/d2hero/hero_state_factory.go

* adding dov.go to d2common/d2geom

* fixing lint errors in d2common/d2loader

* adding doc.go to d2common/d2cache

* adding doc files for d2datautils, d2util, d2path

* adding package doc strings for mapgen, in-geam help screen, and tcp client connection

* removed all cuddling lint errors

* changed stamina equality check to '<=' instead of '<'
2020-10-22 01:12:06 -04:00
Albin 8b2cc76c30
Added ObjectMode, StorePage and Colors.txt resource loaders (#771)
* add ObjMode.txt loader

* add colors.txt loader

* added storepage loader

* Update storepage_loader.go

removed printline

Co-authored-by: kottz <edward.kallstedt@gmail.com>
2020-10-21 11:05:53 -04:00
presiyan-ivanov 88326b5278
Initial cast overlay implementation. Fix HeroSkill deserialization & map entities processing crashing for remote client. (#766)
* Casting a skill now plays the corresponding overlay(if any).

* Prevent a crash caused by nil pointer in HeroSkill deserialization, happening when
unmarshalling HeroSkill from packets as a remote client.

* Add PlayerAnimationModeNone to handle some of the Skills(e.g.
Paladin auras) having "" as animation mode.

* Joining a game as remote client now waits for map generation to finish
before rendering map or processing map entities. This is temporary hack to prevent the game from
crashing due to concurrent map read & write exception.

* Send CastSkill packet to other clients.

Co-authored-by: Presiyan Ivanov <presiyan-ivanov@users.noreply.github.com>
2020-10-10 18:47:51 -04:00
kottz b5e052fc81
Add gamble.txt loader (#764) 2020-10-10 18:45:28 -04:00
Josh Jordan b1cdb47302
Help and Escape Menu click through and close behavior (#761)
* Disallow clicking through the help menu to control the game

* Move Navigator and EscapeMenu up in package tree to be accessible by GameControls. Disallow GameControls input when EscapeMenu is open

* Make ESC key behavior more consistent with D2
2020-10-07 21:20:05 -04:00
nicholas-eden 24556f62fc
Add belt loader (#757)
Add loader and record type for belts #634
2020-09-26 02:13:01 -04:00
Brendan Porter ca45be0948
Adds error handling everywhere (#743)
* 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>
2020-09-23 13:30:54 -04:00
gravestench be354f139b
Removing the rest of the d2data singletons (#742)
* 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
2020-09-20 20:30:27 -04:00
gravestench fc87b2be7a
Removing d2datadict singletons (#738)
* 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
2020-09-20 17:52:01 -04:00
presiyan-ivanov a4e9797431
Initial player Left skill and Right skill handling (#741)
* Initial player Left skill and Right skill handling

* Handle empty skill names in charStats.BaseSkils + add Attack skill for all classes.

Co-authored-by: Presiyan Ivanov <presiyan-ivanov@users.noreply.github.com>
2020-09-20 11:55:44 -04:00
Brendan Porter f4d78549c5
Helpv3 (#739)
* finishing up help overlay

* fixes help overlay close button,
adds hack to prevent buysellbtn from rendering all 24 unrelated frames on top of eachother
2020-09-20 02:54:24 -04:00
gravestench 271673851a
Added RecordManager implementation to remove d2datadict singletons (#736)
* Added RecordManager implementation to remove d2datadict singletons

* fix object lookup test
2020-09-19 14:33:40 -04:00
lord 7e3aff557b
Decouple asset manager from renderer (#730)
* 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

* lint fixes, added data caching to filesystem asset

* adding comment for mpq asset close

* Decouple d2asset from d2render

Notable changes in d2common:
 * d2dcc.Load now fully decodes the dcc and stores the directions/frames in the dcc struct
 * un-exported dcc.decodeDirection, it is only used in d2dcc
 * removed font interface from d2interface, we only have one font implementation
 * added `Renderer` method to d2interface.Surface, animations use this to bind to a renderer and create surfaces as they need
 * added `BindRenderer` method to animation interface

Notable changes in d2common/d2asset:
 * **d2asset.NewAssetManager only needs to be passed a d2config.Config**, it is decoupled from d2render
 * exported Animation
 * Animation implementation binds to the renderer to create surfaces only on the first time it is rendered
 * font, dcc, dc6 initialization logic moved out of asset_manager.go
 * for dc6 and dcc animations, the process of decoding and creating render surfaces has been broken into different methods
 * the d2asset.Font struct now stores font table data for initialization purposes

Notable changes in d2core/d2render:
 * Surfaces store a renderer reference, this allows animations to bind to the renderer and create a surface just-in-time

**These last changes should have been a separate PR, sorry.**
Notable changes in d2core/d2ui:
 * ui.NewSprite now handles creating an animation internally, only needs image and palette path as arguments

Notable Changes in d2game:
Because of the change in d2ui, all instances of this code pattern...
```golang
animation, err := screen.asset.LoadAnimation(imgPath, palettePath)
sprite, err := screen.ui.NewSprite(animation)
```
... becomes this ...
```golang
sprite, err := screen.ui.NewSprite(imgPath, palettePath)
```
2020-09-14 17:31:45 -04:00
lord 7f6ae1b785
improve AssetManager implementation (#728)
* 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
2020-09-14 14:47:11 -04:00
Gürkan Kaymak f4a71c72e4
lint fixes (#727) 2020-09-12 16:25:09 -04:00
lord 3988bd7f1c
d2tbl loader returns string lookup table (#725)
* fix glfw error in ci workflow

* make the tbl loader return the string lookup table (for use in hellspawner)
2020-09-11 19:24:33 -04:00
lord 77c358ed67
d2loader refactor (#722)
* d2loader refactor

- export sources
- asset and source both have a Path method
- make asset and source implement fmt.Stringer, which just calls Path method
- Loader.AddSource now returns the source and an error

* Update loader.go
2020-09-09 14:35:52 -04:00
lord 28a40983ad
move logger into d2util (#720)
* moved logger into d2util

* resolved upstream conflict
2020-09-09 08:22:13 -04:00
Brendan Porter cbb512ab4b
Help Overlay Added (#724)
* Adds help overlay frame and some text and bullets

* Finished basic layout, still need cancel button graphic, behavior
2020-09-09 08:21:27 -04:00
lord 1bcba2701b
update import of d2cache (it was moved in recent d2common refactor) (#721) 2020-09-08 17:39:34 -04:00
lord a0345ef3b1
need to change reference to stream reader after d2common refactor moved it (#719) 2020-09-08 17:39:18 -04:00
lord 65cce60eab
adding animdata loader (#718)
* adding animdata loader

* utility methods, more tests, export record struct

- added methods for fps and frame duration calculation to the AnimationDataRecord
- exported AnimationDataRecord
- split the various structs into their own files
- added getter methods for retrieving records by name
- added tests for the new utility methods
2020-09-08 15:59:38 -04:00
lord 0218cad717
organize d2common pakage (#716)
* 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
2020-09-08 15:58:35 -04:00
lord 50d40fb5d3
D2loader (#714)
* adding logger implementation to d2common

* Adding file loader implementation

The file loader works in terms of `Sources` and `Assets`. A `Source` is
something like a filesystem that has a cache. An `Asset` is something
that implements `io.ReadSeeker` and has a few methods of its own.

There are currently `Source` implementations for MPQ archives and for the
host filesystem, meaning that one can specify a directory on the host fs to
load files from.

`Sources` are added to a loader with `loader.AddSource(path)`, where `path`
resolves somewhere on disk. In the case that the path points to an MPQ,
then an MPQ `Source` is created and added to the loader. If `path` resolves
to a directory, then a filesystem source is added.

Files are loaded with `loader.Load("data/global/excel/monstats.txt")`, and the
sources are searched in the order that they were added.

* adding tests for d2common/logger_test.go

* adding tests and testdata for d2loader

* logger lint fixes, fixed missing test case

* minor edits, lint fixes, changes some comments, embedded Logger into Loader

* moved d2loader into d2common (I dont think it belonged in d2core)

* removed my simple cache implementation in favor of our existing cache in d2common
2020-09-08 15:45:26 -04:00
lord 52125932f8
testing to see if this fixes the github build issues (#715) 2020-09-06 17:09:05 -04:00
Gürkan Kaymak 32a58fd5d3
Added mini panel (#711)
* resolves #685, added mini panel

* formatting
2020-08-25 09:10:26 -04:00
thetogi 41e43ac6be
Display HP/Mana stats when hovering over or clicking respective globe. Update d2debugutil to not use internal package for assets. (#709)
* Set HP/Mana stats when globes are clicked

* Display HP or Mana stat when hovering over globe

* Display HP/Mana stats when hovering globe or when toggling by clicking the respective globe. Rename internal to assets and move assets package into folder.

* Adding .bmp to assets folder
2020-08-24 15:50:33 -04:00
AndrejMijic 2ceba68c73
Add initial calculation string parser (#706)
* Add objgroup.txt loader

* Add parser

* Add parser

* Add tests
2020-08-16 21:56:28 -04:00
Ziemas dccb930f5c
Only draw shadows for layers that should have them (#704)
* Don't draw shadows for transparent layers

* Also use cof shadow setting
2020-08-16 14:59:34 -04:00
Ziemas 8d87c19532
Draw entities back to front within tiles (#705)
* Draw entities per subtile for correct depth order

* Use a temporary entity slice for depth sorting

Speeds things up quite a bit
2020-08-16 14:59:03 -04:00
Gürkan Kaymak 858fa18068
lint fixes (#703) 2020-08-11 18:01:33 -04:00
lord 0ea6bd5b92
add rare prefix+suffix loaders, d2items use rare item names (#702)
* 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
2020-08-06 22:32:40 -04:00
lord 16b8a6467f
fixed most lint errors in d2data (#701)
- moved ds1 object definition into the ds1 dir
- added doc files
- only lint errors remaining are for the unused variables in d2video
2020-08-06 16:45:38 -04:00
lord 33f66badfc
d2enum lint (#700)
* fixing some lint errors in d2enum

* fixed lint errors in d2enum
2020-08-06 16:45:22 -04:00
lord 8b2b991b12
D2mapengine remove entity, minor edits (#694)
* implement entity removal

* add rgba color func, fix some lint errors in d2map

* bugfix for map entity tests
2020-08-05 21:27:45 -04:00
lord 8e41133f39
lint and minor refactor of d2common (#690)
- moved contents of `d2common/math.go` into `d2math/math.go`
- removed lint errors from files in d2common
2020-08-05 00:03:33 -04:00
lord 319e1f0245
fixed lint errors in d2resource (#688) 2020-08-04 23:14:17 -04:00
lord fe992699b5
fix lint errors in d2interface (#684)
- fixed lint errors in d2interface
- removed `archived_` from interface names, was not necessary
- removed the Bitmuncher and Bitstream interfaces, as they are too specific and unnecessary
2020-08-04 22:53:36 -04:00
lord aa4a936fde
fix lint errors in mpq package (#683) 2020-08-04 22:52:54 -04:00
lord 6ef931ddd5
remove lint errors from dt1 package (#682) 2020-08-04 22:23:41 -04:00
lord c3326a30f1
fix lint errors for dc6 package (#681) 2020-08-04 22:23:26 -04:00
lord 120afe51a1
fixed lint errors in d2debututil (#678) 2020-08-04 22:23:15 -04:00
AndrejMijic 4a48acb8ba
Add objgroup.txt loader (#677) 2020-08-04 12:12:03 -04:00
lord 466855e5f5
remove lint errors from d2datadict (#676) 2020-08-04 11:16:06 -04:00
AndrejMijic c216ddab53
Add monpreset.txt loader (#675) 2020-08-04 09:06:33 -04:00
Bojan Novković 0e1b30b91a
Added loaders for compcodes.txt, events.txt and monai.txt (#665)
* added loaders for compcodes.txt, events.txt and monai.txt

* fixes in response to PR comments

Co-authored-by: BojanoN <bojan.novkovic@kset.org>
2020-08-02 21:27:33 -04:00
AndrejMijic efb554c42b
Add PlayerClass.txt loader (#667) 2020-08-02 21:26:57 -04:00
lord 524132c122
D2datadict unique items bugfix (#669)
* d2ui.Label: add support for color tokens in labels, multiple colors per label

* unique items should use the item name as the map key
2020-08-02 21:26:07 -04:00
lord 6a8b9aada1
Minor edits: debug entity frame bounds, debug `spawnmon` command (#666)
* adding debug printing boxes for entity bounds

* minor edits

- adding `spawnmon` command. currently does not have a netpacket, just for debug
- adding `GetSize` method to map entities for getting frame bounds (for debug printing)

* bug fix
2020-08-01 19:03:09 -04:00
AndrejMijic 6514fd15de
Add monseq.txt loader (#664) 2020-08-01 17:55:34 -04:00
AndrejMijic 3fea5a096d
Add monequip.txt loader (#662) 2020-07-31 18:24:47 -04:00
Bojan Novković 247bda97c6
Added loaders for itemratio.txt, Overlay.txt and UniqueAppellation.txt (#660)
* Added loaders for itemratio.txt, Overlay.txt, UniqueAppellation.txt

* Adjust unique appellation loader for expansion data

* fixes: response to PR comments

* overlay.go: PR comment fixes

Co-authored-by: Bojan Novkovic <bojan.novkovic@kset.org>
2020-07-31 18:14:41 -04:00
Bojan Novković 38852d0285
added loaders for misscalc.txt and skillcalc.txt (#661)
Co-authored-by: BojanoN <bojan.novkovic@kset.org>
2020-07-31 18:00:10 -04:00
AndrejMijic 44e84c8b10
Add MonSounds.txt loader (#658) 2020-07-31 17:56:00 -04:00
AndrejMijic 05fa7d93ce
Add monlvl.txt loader (#655) 2020-07-31 15:00:09 -04:00
Ziemas c840e140f7
Stereo panning for sound effects (#654)
Randomly pan event sounds

Adapted from ebiten example
2020-07-30 21:50:27 -04:00
AndrejMijic 42cd1e1a3b
Add monumod.txt loader (#653) 2020-07-30 21:49:29 -04:00
Ziemas 29ea71489d
Sound engine and sound environments (#652)
* Working sound engine and sound environments

* Clean up sounds.txt loader

* Make global volume settings apply properly

Als shuffle some stuff around

* Reset sound engine on game unload
2020-07-30 16:17:26 -04:00
lord 78ecc3557e
simple item spawning in map (#651)
* wip d2items system and item properties

* added loader for TreasureClassEx.txt

* wip item spawn from treasure class records

* wip items

* add call to init item equivalencies, remove treasure class test from d2app

* made item affix records global var a map of affix codes to the records

* changed how item to item common record equivalency is determined

* changed set items records export to a map of their codes to the records, grouped property params into a struct

* changed property parameter field from calcstring to string

* fixed bug in stat value clone

* adding equipper interface as part of stat context, eventually to be used to resolve set bonus (among other things)

* made the item interface simpler, only needs name and description methods

* adding equipper interface, for anything that will equip or have active items

* handle case where min and max are swapped, removed commented code

* added property/stat resolution for magic, rare, set, and unique items

* adding item generator which can roll for items using treasure class records

* fixed item equivalency func being called in the wrong spot

* added item spawning

- added packet type for spawning items
- added client/server handlers for SpawnItem packets
- added map entity for items
- added simpler item provider function in diablo2item package
- added debug terminal command for spawning items
2020-07-30 15:04:05 -04:00
AndrejMijic 9789372e8f
Add npc.txt loader (#650) 2020-07-30 14:12:18 -04:00
AndrejMijic 333b8610ac
Add pettype.txt loader (#648)
* Add pettype.txt loader

* Remove go.mod replace
2020-07-30 11:31:32 -04:00
lord bfd3f1046d
D2items WIP (#646)
* wip d2items system and item properties

* added loader for TreasureClassEx.txt

* wip item spawn from treasure class records

* wip items

* add call to init item equivalencies, remove treasure class test from d2app

* made item affix records global var a map of affix codes to the records

* changed how item to item common record equivalency is determined

* changed set items records export to a map of their codes to the records, grouped property params into a struct

* changed property parameter field from calcstring to string

* fixed bug in stat value clone

* adding equipper interface as part of stat context, eventually to be used to resolve set bonus (among other things)

* made the item interface simpler, only needs name and description methods

* adding equipper interface, for anything that will equip or have active items

* handle case where min and max are swapped, removed commented code

* added property/stat resolution for magic, rare, set, and unique items

* adding item generator which can roll for items using treasure class records

* fixed item equivalency func being called in the wrong spot
2020-07-30 10:14:15 -04:00
AndrejMijic 4dc0aa0f48
Add PlrMode.txt loader (#647) 2020-07-30 09:53:41 -04:00
AndrejMijic a1ea22c81f
Add reading of ElemTypes.txt (#644) 2020-07-30 02:41:19 -04:00
Andrew Doing cec3fb91d8
Add shrines.txt loader (#642) 2020-07-29 18:03:06 -04:00
Greg Jones 50fd6608cf
d2datadict: Add books.txt loader (#640) 2020-07-29 17:26:20 -04:00
Huw Griffiths a31fb173eb
d2datadict: Add Monmode.txt loader (#638) 2020-07-29 08:38:34 -04:00
Andrew Doing 6f30dffa1c
d2datadict: Add soundenviron.txt loader (#639) 2020-07-28 16:35:22 -04:00
Huw Griffiths 78470431d6
d2datadict: Add Montype.txt loader (#637) 2020-07-28 16:34:01 -04:00
Huw Griffiths b7f8aa8e90
d2datadict: Add Monprop.txt loader (#636) 2020-07-28 07:54:05 -04:00
Huw Griffiths 35d936ac4e
d2datadict: Add runes.txt loader (#635) 2020-07-28 07:53:32 -04:00
Andrew Doing 495301a9b7
Add loading of states.txt (#633)
* Add loading of states.txt

* Lint states.go
2020-07-28 07:52:55 -04:00
lord 0018044c83
D2data treasure class (#631)
* added loader for TreasureClassEx.txt

* fix lint error
2020-07-27 01:16:37 -04:00
Tim Sarbin 460e821a5e
Started work on shadows (#630) 2020-07-26 19:29:37 -04:00
Tim Sarbin 856043d8ac
Updated music logic (#629) 2020-07-26 15:17:00 -04:00
Tim Sarbin 7da1843f49
Lint cleanup (#628) 2020-07-26 14:52:54 -04:00
Tim Sarbin 53599928f7
re-ordered structures to optimize memory layout (#627) 2020-07-26 13:23:46 -04:00
Tim Sarbin 63aa1eebe9
Fix bad file names (#626)
* Fixed bad capitalization in names

* More bad name fixes

* temp rename for case sensitivity issues

* Temporary rename to fix capitalization
2020-07-26 13:06:37 -04:00
Tim Sarbin 8c8ab94f8c
Remove star, update refs. (#625)
* Added patreon supports to credits

* Remove astar path finding code.
2020-07-26 12:55:10 -04:00
Huw Griffiths 5e395092e7
Add qualityitems.txt loader (#622) 2020-07-25 09:37:43 -04:00
danhale-git 259c6e7e76
Vector method pointers (#621)
* All Vector methods which operate on the vector return pointers to it.

* All Vector methods which take vectors take Vector pointers.
2020-07-25 09:36:54 -04:00
lord b13175b070
d2data item related loaders (#619)
* added loader for ItemTypes.txt

* added loader for bodylocs.txt

* lint fix for item_types loader

* adding loader for sets.txt

* minor edit

* adding loader for SetItems.txt

* added loader for automagic.txt
2020-07-24 21:56:19 -04:00
Gürkan Kaymak 1ce81f1aec
fixed Id renaming in strings (#618) 2020-07-24 07:54:52 -04:00
Gürkan Kaymak 7a49f3637f
lint fixes (#615) 2020-07-23 12:56:50 -04:00
Gürkan Kaymak 80e655964e
Removed some global variables (#611)
* removed some global variables

* fixed tests
2020-07-22 15:03:03 -04:00
lord 362147848d
entity debug rendering (#609)
* entity debug rendering, with command

needed to add getter method to MapEntity interface, so that's the reasoning for changing objects/npcs/player/etc

this currently brings allocs/s up to 10 (you can check by running `fps` command, se we need to look into d2debugutils and how it handles drawing text

* reverting velocity copy, broke the map entity tests. debug display wont show velocity currently.

* adding velocity debug
2020-07-21 08:51:09 -04:00
Ziemas d0c6cd61dd
Simple LOS pathfinding without walkmesh (#610)
* Reorganize MapEngine

This is already turning into a mess...

* Map engine selects tile index to use

Still very ugly

* Fix subtile flag combination

* Prepare randomly generated base tiles

* Restore collision viewer

* Movement works again, searches for straight paths

Paths are now d2vector slices

* Fix LOS calculation

* Fix test (I think)
2020-07-21 08:50:45 -04:00
lord 6db299b31d
remove most lint errors in d2common (#606)
* removed magic numbers from stream reader/writer and bitstream

* formatting, removing a couple more magic numbers
2020-07-18 18:07:38 -04:00
danhale-git 727e8244c6
Implemented Position in Path and PathTile (#605)
* Unnecessary constructor assignments removed.

* Position implemented in d2common.Path

* Position implemented in mapEntity.Step.

* Position implemented in d2common.PathTile.
2020-07-18 18:07:13 -04:00
dk 093ea3682e
fixing most of the remaining lint errors in d2fileformats (#600) 2020-07-18 00:02:45 -04:00
dk ba89bf965a
removing lint errors from d2render (#598)
The edits outside of d2render or to fix the lint error for `DrawText`.
`DrawText` should be called `DrawTextf` because it formats the string.
2020-07-17 18:51:44 -04:00
dk 1654fd7e90
Removing lint errors in npc.go, mapstamp.go (#597)
- made an enum for NPCActionType to get rid of magic numbers
- moved the enum to d2enum
- fixed lint errors in npc.go
- fixed lint errors in mapstamp.go (because it was using npc.go)
2020-07-17 18:51:19 -04:00
dk cf6029eb95
Stat descriptions + tests, Skilldesc.txt loader (#590)
* adding ranged number type, for use in stats

* Loaded Skills.txt

* asset manager only binds terminal commands if terminal != nil

* WIP stats

* cache getter and clear methods were not implemented

* asset manager handles a nil terminal pointer

* adding skilldesc.txt loader (needs work)

* ctc stat descriptions functions working

* moving description functionality out of itemstatcost loader and into stats

* stats seem like a central part of diablo, moving into d2core.

* stats seem like a central part of diablo, moving into d2core.

* delint

* adding statlist, statlist reduction, unit tests

* minor edits to stat.go

* lint error in statlist.go

* Remove dependency on actual data from mpq files

stats unit tests now use mock data

* fixing some lint errors, formatting

Co-authored-by: Maxime Lavigne (malavv) <duguigne@gmail.com>
2020-07-17 18:50:45 -04:00
danhale-git 54ff33c552
Benchmark d2math (#595)
* Vector and tests reviewed.

* Tests and benchmarks for d2math.math.

Also docs/comments.
2020-07-17 18:50:07 -04:00
danhale-git dcb0c087b9
Vector benchmark (#594)
* Reflect and ReflectSurface benchmark.

* Rotate, NinetyAnti and NinetyClock benchmark.

* Equals, EqualsApprox, CompareApprox and IsZero benchmark.

* Benchmarks for everything else.

Also removing dead functions and commented out code and correcting typos.
2020-07-16 14:13:01 -04:00
danhale-git 921d44a70c
mapEntity.Step() benchmark and improvements. (#593)
* Initial test and benchmark for mapEntity.Step().

* Removed `&& !m.hasPath()` from mapEntity.atTarget

* Direction is now updated when the path node changes mid-step and target is updated when path is set.

* Test improvements.

* Deleted old benchmark function and tidying.

* d2math.Abs added.

* Abs benchmark and optimisation.

* Negate and Distance benchmark.

* Length and SetLength benchmark.

* Lerp and Dot benchmark.

* Cross and Normalize benchmark.

* Angle and SignedAngle benchmark.

* Trivial change to Vector.Abs()
2020-07-16 12:06:08 -04:00
Maxime Lavigne (malavv) 06b80cf24f
Loaded Skills.txt (#583) 2020-07-14 06:59:49 -04:00
danhale-git 894c60f77a
Map entity rework - vectors in mapEntity (#579)
* Fixed NaN on normalize 0 vector.

* Tentative implementation in getStepLength.

* mapEntity.TileX/Y removed.

* Fixed Position and Target not being initialised in createMapEntity.

* mapEntity.Position is no longer embedded.

* mapEntity.LocationX/Y no longer used outside map_entity.go.

* mapEntity.subCellX/Y removed.

* mapEntity.LocationX/Y removed.

* mapEntity.OffsetX/Y and TargetX/Y removed.

* Direction method added to Vector, returns 0-64 direction.

* Moved Vector.Direction() to Position.DirectionTo and refactored.

* Renamed RenderOffset from SubCell and tested IsZero.

* d2math.WrapInt added for use with directions.

* Tidied up position and tests.

* Refactored d2common.AdjustWithRemainder into d2mapEntity.

* Tidying up d2mapEntity.

* Final cleanup.

* Lint warnings.

* Spelling correction.
2020-07-13 09:06:50 -04:00
Sunny Klair 41e7a5b28b
Add static checks to help ensure implementations conform to interfaces (#582) 2020-07-13 09:05:04 -04:00
dk 7a32e7bbac
adding ranged number type, for use in stats (#581) 2020-07-13 09:03:19 -04:00
dk 8c16ea2880
Properties.txt loader (#580)
* adding loader for properties.txt

* adding resource path for properties.txt

* adding call to properties loader

* typo
2020-07-13 09:02:09 -04:00
dk 8577dfc3aa
set compositing on debug print so text bg is transparent (#578) 2020-07-11 20:33:20 -04:00
thetogi 7b60882ba3
Replace ebitenUtil with d2DebugUtil and new charmap for debugger. (#577)
* lint updates for /d2astar

* png issue

* debug package

* load bmp properly

* debug draft

* Vector float64 (#565)

* Fixed nil pointer in Copy()

* Position added

Added Floor() and String() methods to Vector.

Also added Position which declares an embedded Vector2 and returns various forms of it.

* d2vector.Vector2 renamed to d2vector.BigFloat

* vector.go renamed to big_float.go

* Float64 stub and more renaming

* Vector value getters

* Separate vector types with initial methods.

* Divide and lint warnings.

* Distance and Length.

* Scale, Abs and Negate.

* CompareFloat64Fuzzy delta direction reversed.

* Refactor vector_test.go.

* Renamed Approx methods.

* Distance and Length.

* Distance and Length.

* Removed BigFloat and Vector, renamed Float64 to Vector, simplified tests.

* Angle, SignedAngle and other small functions.

* Receiver rename.

* SingedAngle and test fixed

* Rotate.

* SetLength.

* Cross.

* NinetyAnti and NinetyClock.

* Lerp and Clamp.

* Reflect and ReflectSurface.

* Cardinal convenience functions.

* Comments.

* Panic on NaN and Inf in Position.

* Lint warnings and comments.

* D2map lint warnings (#566)

* Comments and newlines in engine.go

* Comments and newlines in object.go

* Comments and newlines in animated_entity.go

* Comments and newlines in missile.go

* Comments and newlines in npc.go

* Comments and newlines in player.go

* Removed object.go (incorrectly merged it in during rebase).

* Comments and newlines in renderer.go.

* Comments and newlines in map_entity.go.

* Comments and newlines in walk_mesh.go.

* Comments and newlines in viewport.go and tile_cache.go.

* Comments and newlines in stamp.go and wilderness_tile_types.go.

* Comments and newlines in everything else.

* removing inventory grid test for now because it causes builds to fail on github (#570)

* Refactored d2enum (#567)

* Refactored animation mode enum

* More d2enum changes

* Refactored tile enum

* Refactored weapon class enum

* Refactored more enums

* Refactored item event enum

* Fixed init_functions animation mode

* Removed string2enum from MonsterAnimationMode

* Refactored ItemStatCost description

* Last enum lint errors

* Regenerated monster stringer file

* compressed image

* Replaced restruct with StreamReader (#574)

* Fixed bug in palette.go (#575)

* Javascript console commands (#572)

* Allow the execution of JS from the terminal when hosting a local game or playing a single game

Signed-off-by: William Claude <w.claude@thebeat.co>

* Reorganise imports on edited files

Signed-off-by: William Claude <w.claude@thebeat.co>

* Remove Reset

Signed-off-by: William Claude <w.claude@thebeat.co>

* Add inventory.txt loader, use the records (#573)

* adding resource entry for inventory.txt

* adding loader for inventory.txt

* adding call to inventory.txt loader in d2app

* d2game now uses the inventory.txt records for making the inventory panel

* removed comments

* remove unused files

* update go.mod

* lint updates for /d2astar

* png issue

* update go.mod

Co-authored-by: danhale-git <36298392+danhale-git@users.noreply.github.com>
Co-authored-by: dk <dknuth0101@gmail.com>
Co-authored-by: Intyre <Intyre@gmail.com>
Co-authored-by: William <1004323+aziule@users.noreply.github.com>
2020-07-11 18:12:20 -04:00
danhale-git fa0814e0b1
Position supports current coordinate types. (#576) 2020-07-11 18:11:26 -04:00
dk 3aab0515cf
Add inventory.txt loader, use the records (#573)
* adding resource entry for inventory.txt

* adding loader for inventory.txt

* adding call to inventory.txt loader in d2app

* d2game now uses the inventory.txt records for making the inventory panel
2020-07-11 11:25:34 -04:00
Intyre aecd047cf3
Replaced restruct with StreamReader (#574) 2020-07-10 23:02:45 -04:00
Intyre 9e58b134e5
Refactored d2enum (#567)
* Refactored animation mode enum

* More d2enum changes

* Refactored tile enum

* Refactored weapon class enum

* Refactored more enums

* Refactored item event enum

* Fixed init_functions animation mode

* Removed string2enum from MonsterAnimationMode

* Refactored ItemStatCost description

* Last enum lint errors

* Regenerated monster stringer file
2020-07-09 23:12:28 -04:00
danhale-git 029cb62972
Vector float64 (#565)
* Fixed nil pointer in Copy()

* Position added

Added Floor() and String() methods to Vector.

Also added Position which declares an embedded Vector2 and returns various forms of it.

* d2vector.Vector2 renamed to d2vector.BigFloat

* vector.go renamed to big_float.go

* Float64 stub and more renaming

* Vector value getters

* Separate vector types with initial methods.

* Divide and lint warnings.

* Distance and Length.

* Scale, Abs and Negate.

* CompareFloat64Fuzzy delta direction reversed.

* Refactor vector_test.go.

* Renamed Approx methods.

* Distance and Length.

* Distance and Length.

* Removed BigFloat and Vector, renamed Float64 to Vector, simplified tests.

* Angle, SignedAngle and other small functions.

* Receiver rename.

* SingedAngle and test fixed

* Rotate.

* SetLength.

* Cross.

* NinetyAnti and NinetyClock.

* Lerp and Clamp.

* Reflect and ReflectSurface.

* Cardinal convenience functions.

* Comments.

* Panic on NaN and Inf in Position.

* Lint warnings and comments.
2020-07-09 08:30:55 -04:00
Ziemas e2e8a303c2
Use our own DrawEffects enum for draw effects (#564)
* Add PushEffect, handle effects in renderer

* Set effects instead of blend

* Stop using PushCompositeMode, use PushEffect

* Remove remaining composite mode things
2020-07-08 21:57:35 -04:00
Intyre a10a53be26
Renamed EquippedSlot enum (#563) 2020-07-08 19:08:07 -04:00
Ziemas 1ad3c72211
Standardize indexed color to RGBA conversion to one function (#562)
* Common function for indexed color to rgba

* Use ImgIndexToRGBA when decoding tiles

* Pass DrawEffect down to animation
2020-07-08 17:46:45 -04:00
Maxime Lavigne (malavv) f18ede6e66
Removing Clone of Font() since all material is sharable, Fixes #515 (#561)
* Removing Clone of Font() since all material is sharable, Fixes #515

* Removed Clone() from the Font interface, as deep copies are not needed.
2020-07-08 11:25:40 -04:00
Gürkan Kaymak d1f499fb79
lint fixes for the d2common package (#558) 2020-07-08 09:16:56 -04:00
Intyre db5e844aac
Removed Configuration interface (#560) 2020-07-08 09:16:16 -04:00
Ziemas 38213e749a
Some slight DC6 cleanup (#557) 2020-07-08 09:14:09 -04:00
Ziemas 252e6c6c23
Clean up monstats2 (#555) 2020-07-07 15:04:18 -04:00
Intyre 04c7ff543a
d2datadict reading changes (#553)
* Read excel files with csv.Reader

* Read LvlWarp from txt file

* Fix lint issues in d2datadict

* changed ID back to Id
2020-07-07 08:56:31 -04:00
dk 60e6fcb7ac
moving enumerations out of d2interface (#552)
* moved filter constants back to d2enum

* moving key and mouse button enums into d2enum

* moving render type enum into d2enum

* moving input even priority enums into d2enum

* moving terminal enums into d2enum
2020-07-06 21:26:08 -04:00
Gürkan Kaymak 473a0b3b19
Remaining lint fixes for the d2gamescreen package (#550)
* lint fixes for the game.go

* lint fixes for the gui_testing.go

* lint fixes for the blizzard_intro.go, map_engine_testing.go and select_hero_class.go

* added package comment for the d2gamescreen package

* fixes after merge
2020-07-06 20:13:55 -04:00
Ziemas 5212270c44
Split up DCC/DC6 animation implementations, decode directions on demand (#548)
* Split DCC and decode direction on demand

* Clean up

* More cleanup

* Make dc6 animation it's own type

* Make base animation private

* Also decode DC6 directions on demand
2020-07-06 20:13:06 -04:00
dk 321a353461
Font manager abstraction (#545)
* abstracted palettes, colors, and palette manager

* make asset manager use the palette manager interface

* added BGRA setter/getter, fixed lint errors

* abstraction for animation and animation manager

* abstracted font and font manager
2020-07-05 15:56:48 -04:00
dk c1a88c9cf7
Animation manager abstraction (#544)
* abstracted palettes, colors, and palette manager

* make asset manager use the palette manager interface

* added BGRA setter/getter, fixed lint errors

* abstraction for animation and animation manager
2020-07-05 13:01:44 -04:00
dk 8809fb2c22
Made abstractiong for the file manager (#542)
I realized that the file manager is actually managing file access
to the archives, but it's doing so through the archive manager.

I've renamed it, it's now called ArchivedFileManager because that
is really what it is.
2020-07-05 00:00:00 -04:00
dk 0a72ccaf16
Abstraction for archives and archive manager (#541)
* archive abstraction

* archive manager abstraction

* fixinglint errors

* archive abstraction

* archive manager abstraction

* fixinglint errors
2020-07-04 22:37:13 -04:00
danhale-git 07d90e9681
Position struct for managing world coordinates (#540)
* Fixed nil pointer in Copy()

* Position added

Added Floor() and String() methods to Vector.

Also added Position which declares an embedded Vector2 and returns various forms of it.

* Position tests improved
2020-07-04 19:25:53 -04:00
danhale-git 853ad7ae64
Cardinal vectors (#539)
* Comments and newlines in vector.go

* Added cardinal direction functions.

* Moved vector.go into d2vector.
2020-07-04 08:02:47 -04:00
dk cf35285b48
abstracted d2config to an interface (still have a singleton, though) (#538) 2020-07-04 00:49:16 -04:00
Ziemas 3757ff1ac5
New package d2object, first object initFun (#537)
* Move MapEntity to d2interface

* New package d2object, first object initFun

Moves objects out to their own package and implements the very first
init function, torches/braziers now gets their animation mode set at creation.

* Apply name again

* Turn on waypoints
2020-07-04 00:48:31 -04:00
Ziemas 6269726316
Composite work (#536)
* Quit using ObjectLookupRecord in composite

* Unexport SetMode in map entities

* Get rid of weaponClass from MapEntity

* Pass ObjectType to composite instead of string

* Use layer weaponclass from cof

* Manage more stuff directly in composite

* Explicitly index when picking equipment
2020-07-03 22:52:50 -04:00
dk 4c3ff12cba
abstracted cache to an interface (#535) 2020-07-03 21:23:44 -04:00
dk de116e8367
moving package comments into doc.go files (#534) 2020-07-03 18:33:46 -04:00
dk 18003a8543
fixed lint errors in d2astar (#533)
* fixed lint errors in d2astar

* Update astar.go
2020-07-03 18:33:14 -04:00
dk 62b8a610c0
D2input abstraction (#532)
* abstract d2input manager/service/events/keys/buttons to interface

* abstract d2input manager/service/events/keys/buttons to interface

* fixing lint error
2020-07-03 15:09:16 -04:00
Ziemas 7ce01ab694
Create objects by passing the object record to CreateObject (#530)
* Create object by Objects.txt entry

Get graphics token from objectType

* Unexport some unused ObjectRecord stuff.
2020-07-03 10:38:22 -04:00
dk 48bde64a7e
vector implementation with big.Float (#527) 2020-07-03 02:26:59 -04:00
Ziemas e21e39e227
Fix d2datadict.Objects index (#525) 2020-07-02 21:55:10 -04:00
Maxime Lavigne (malavv) 973e969002
Working on d2input.go for #487 (#514)
d2input/ is now clear of lint.
2020-07-01 14:03:40 -04:00
Ziemas 0272b593fb
Cof direction lookup (#517)
Generated these based on the d2dcc direction lookup hopefully they're
correct (they seem to be at least)
2020-07-01 14:02:47 -04:00
thetogi 5b26624cb8
lint updates for /d2astar (#507) 2020-07-01 00:13:25 -04:00
Ziemas fa20b9ee51
Spawn monster by monstat record (#508)
* DS1 reader no longer looks up objects

* Start of enteties managing their own equipment

* stringer and string2enum CompositeType

String2enum

* Use CompositeType stringer to simplify composite

* Finally fix GetDelimitedList

And lint issues

* NPC selects random equipment
2020-07-01 00:06:06 -04:00
Gürkan Kaymak ae6bfb839e
Lint fixes for the following packages (#505)
* fixed lint issues of the package d2core/d2inventory

* fixed lint issues of the d2script package

* fixed lint issues of the d2common/d2interface package

* fixed lint issues of the d2common/d2resource package

* fixed lint issues of the d2core/d2term package

* fixed conflict errors
2020-06-30 17:04:41 -04:00
Maxime Lavigne (malavv) 3990df3bac
Fixes #496 and improves memory consumption on render of game_controls (#501)
* Fixes #496 using ebiten.SubImage to Render Section of a Surface.

I had to add matching functions to both animation and sprite to get it to be called
for a sprite object.

* Fixed linter warning on comments for Sprite and Animation.

* Removing what's remaining of the old Sprite re-generation and caching.
2020-06-30 12:43:13 -04:00
Tim Sarbin e2572b8745
More linting (#500) 2020-06-30 09:58:53 -04:00
dk 4938ec1f44
Resolved most lint errors in d2data and d2datadict (#499)
* adding comments to d2interface for linter

* moved d2render renderer interfaces and types into d2interface

* fixed most lint errors for monstats loader

* de-lint d2data wip

* d2data: resolve linting errors
2020-06-30 09:17:07 -04:00
dk 691368cba7
Decouple bitmuncher (#495)
* adding comments to d2interface for linter

* moved d2render renderer interfaces and types into d2interface

* fixed most lint errors for monstats loader

* decouple bitmuncher to interface
2020-06-29 20:21:09 -04:00
dk 06202a2ddf
fixed monstats lint errors, added doc file for d2datadict (#494)
* adding comments to d2interface for linter

* moved d2render renderer interfaces and types into d2interface

* fixed most lint errors for monstats loader
2020-06-29 18:46:31 -04:00
Ziemas eb69eebcc1
Fix string splitting on delimited list (#493)
Would include extraneous quotation marks

Also fix mistake in monstats2
2020-06-29 18:45:41 -04:00
Ziemas aae565d528
Monstat2 loading and a bunch of lint issues (#491)
* MonStat2 loader

* Fix a bunch of lint issues in d2datadict
2020-06-29 12:37:11 -04:00
Tim Sarbin b29e7c8fdd
Updated ebiten. Fixed hash entry map data leak. (#489) 2020-06-29 10:53:25 -04:00
dk 55dc3e42ed
minor edits (#486)
* adding comments to d2interface for linter

* moved d2render renderer interfaces and types into d2interface
2020-06-29 00:41:58 -04:00
Tim Sarbin 255ffc75da
Fixed lint issues (#484) 2020-06-28 22:32:34 -04:00
dk 09a28c2822
removed d2term singleton (#483) 2020-06-28 21:40:52 -04:00
Tim Sarbin 3f575cf1d8
Removed audio singleton (#482) 2020-06-28 19:31:10 -04:00
Ziemas a86f27bf0f
Let HellSpawner get at the string translation map (#479) 2020-06-28 10:33:09 -04:00
Ziemas 6c56027731
Fix monpreset for other acts (#478) 2020-06-28 00:07:52 -04:00
Ziemas 3f1fe538e2
Load monpreset and use that to find monstat entries for NPC's (#477)
* Load monpreset.txt

* Get monstat for npc's and their name from strings

Using monpreset to grab the key for monstat

* Object name tags
2020-06-27 23:15:20 -04:00
Ziemas 11f743aa42
Get and use draw order and animation speed for objects (#473)
* String2enum ObjectAnimationMode

* Render objects at their assigned layer

Gets the orderflag from the object record and assign it to the mapentity
so the renderer can get at it.

This adds another render pass that loops through the objects.

* Get object animation speed from their txt entry
2020-06-27 14:30:23 -04:00
Tim Sarbin 66e6d32680
Added all music definitions (#472) 2020-06-27 03:16:53 -04:00
Tim Sarbin 490c00b7b2
Added audio streaming capabilities (#471) 2020-06-27 02:49:27 -04:00
Tim Sarbin 1ca534cc13
Revert "Refactor d2map (#468)" (#469)
This reverts commit fe47e51351.
2020-06-26 17:12:19 -04:00
dk fe47e51351
Refactor d2map (#468)
* WIP refactor of d2map stuff

* more d2map refactor

adding realm init to game client
passing map engine from client and server into realm at init
change `generate map packet` to have act and level index as data

* client explodes, but getting there

* realm now initializes, networking works, but map generators dont currently do anything

* changed the way that level type records are loaded

* fixed funcs for level data lookups

* started implementing level generator, currently crashing

* client no longer exploding

* d2networking refactor

put exports into d2client.go and d2server.go
kept GameClient and GameServer methods into their respective files
made methods for packet handlers instead of the giant switch statements

* bugfix: getting first level id by act

* minor refactor of gamescreen for readability

* towns now generate on server start, create player takes act and level id as args, levels have their own map engine
2020-06-26 16:50:24 -04:00
presiyan-ivanov c64e9be78b
Character stats (#458)
* Save/load hero stats and display them in stats panel.

* Load default hero state for characters created before saving stats was introduced

Co-authored-by: Presiyan Ivanov <presiyan-ivanov@users.noreply.github.com>
2020-06-25 14:56:49 -04:00
Ziemas 02605227c3
Various map entity reworks (#439)
* Use integer directions for rotating map entities

* Manage composite directly in npc

* Player manages its own composite

* Split up animation mode types

Players, monsters, objects all have their own types

* Clean up AnimatedEntity

* Rename AnimatedEntity -> Object

* Keep the object txt record on hand in Object
2020-06-24 13:49:13 -04:00
Tim Sarbin 954670da5f
Fixed linting issues (#438) 2020-06-24 10:13:11 -04:00
nicholas-eden 329e2f0fab
Use closest path if path not found (#431)
When clicking on the other side of a wall or in an an inaccessible area,
route the player the closest possible node.  This allows running along
walls and matches the original closely.

Co-authored-by: Nicholas Eden <neden@zigzagame.com>
2020-06-24 08:09:00 -04:00
Tim Sarbin a24c05efa9
Map generation and test fixes (#430)
* More mapgen updates

* Added east generation

* Added west town generation

* Fixed test errors
2020-06-24 00:04:27 -04:00
danhale-git 897de61006
Automap corrections (#422)
* Added automap.go stub

* Handle errors in original AutoMap.txt file

* Completed AutoMapRecord struct and comments

* AutoMap loader implemented

* Update from base repo

* Cel1-4 fields replaced with a slice

* Commented out Type fields as they aren't used
2020-06-23 14:51:07 -04:00
Intyre f119d1197c
Fix mpq wav decompression and profiler (#423)
* Fix for mpq wav decompression

* Fix for profiler
2020-06-23 14:49:46 -04:00
Ripolak 2332bd7b58
Feature/player equipment ui (#419)
* Add basic EquipmentSlot struct

* Add Load function to EquipmentSlot

* Move EquipmentSlot struct to inventory_grid.go

* Add equipmentSlots arg to ItemGrid struct

* Add basic rendering of equipment slots.

* Change rendering of equipment slots to simply use their static x and y

* Add ChangeEquippedSlot function

* Add initialization to all equipped slots types.

* Fix Y locations of equipment slots

* Move default equipment slots to a genEquipmentSlotsMap function.

* Change Item to item

* Fix coordinates

* Change usage of string to EquippedSlotType when dealing with different slots in rendering.

* Fix import error

* Remove neck example

* Add loading sprites of equipped items.

* Clean code in Inventory rendering

* Clean code in Inventory rendering

* Clean code in Inventory rendering

* Change default items that get rendered.

* Change default items that get rendered.

* Add width and height to EquipementSlot struct

* Fill in width and height to current equipment slots.

* Fix Y setting of equipment slots

* Rename variables for clean code.

* Change handling nil itemSprite to condition instead of loop return.

* Split Render function to 2 functions.

* Add TODO

* Change comment to start with capital I
2020-06-23 14:12:30 -04:00
Gürkan Kaymak 7f4db3b874
Added call to loading SuperUniques data dict (#415)
* added SuperUniques data dictionary

* added a call to LoadSuperUniques() method from the main

* added a call to LoadSuperUniques() method from the main
2020-06-23 09:30:39 -04:00
Gürkan Kaymak 1cc5b0bfbd
added SuperUniques data dictionary (#414) 2020-06-23 09:12:35 -04:00
nicholas-eden dd21809288
Pull go-astar code into the repo, improve perf (#411)
Copied go-astar into d2common/d2astar, made a few optimizations.  Runs
roughly 30% faster according to my benchmarking.

Added a `maxCost` param to prevent searching the entire map for a path.
This probably needs tweaked a bit, but follows the original game more
closely.

Co-authored-by: Nicholas Eden <neden@zigzagame.com>
2020-06-23 02:04:17 -04:00
danhale-git fe0fa6f14d
Feature/cubemain (#410)
* Added automap.go stub

* Handle errors in original AutoMap.txt file

* Completed AutoMapRecord struct and comments

* AutoMap loader implemented

* Update from base repo

* Added cubemain.go stub

* Input and requirement fields

* Removed CubeRecipeRequirement added CubeRecipeResult

* Comments and some name changes

* Implemented cubemain.go

* Corrected log line
2020-06-23 02:02:35 -04:00
Tim Sarbin c2db7ede66
Added basic map generation for first area of south town (#408)
* Map engine updates. Limited rendering to specific area.

* Added south town border generation
2020-06-23 01:05:01 -04:00
Intyre d17db5b1d1
StreamWriter: replaced slice with bytes.Buffer (#402) 2020-06-22 18:56:20 -04:00
dk 953271b8e6
minor edits (#401)
* make game update at 25fps, ui update at max fps

* minor edits to func names, d2resource constants

* renamed `loadDictionary` to `loadTextDictionary` to avoid confusion with `LoadDataDictionary`
* updated line in main.go that calls `loadTextDictionary`
* added tokens as constants inside of `d2resource/resource_paths.go` that are used in font/language paths
* moved locale string handling stuff into it's own func, now uses tokens defined in d2resource

* minor edits to func names, d2resource constants

* renamed `loadDictionary` to `loadTextDictionary` to avoid confusion with `LoadDataDictionary`
* updated line in main.go that calls `loadTextDictionary`
* added tokens as constants inside of `d2resource/resource_paths.go` that are used in font/language paths
* moved locale string handling stuff into it's own func, now uses tokens defined in d2resource

* fix: accidentally renamed func in d2asset

* git is hard

accidentally added changes not meant for this commit
2020-06-22 17:36:45 -04:00
Intyre 0c27ae63e6
MPQ memory improvements (#399) 2020-06-22 16:01:14 -04:00
Haashi 5e1725dd7d
385/lintissues (#391)
* camera offset for ui panels :

added maprenderer viewport to be aligned left or right

calling alignement on keyPress in game_controls

* check if already aligned

* fix bugs

-forgot to assign alignement
-defaultScreenRect instead of screenRect because of issue mentionned in original comment

* remove config.json and replace go.mod line

* removing duplicate import of d2common

replacing all dh to d2common

* remove useless breaks from switch statement

* better range when value unused + prettying import

* item_affix rewrite

using return values instead of pointer references in arguments

* ebiten deprecated calls

* small fixes
2020-06-22 11:53:44 -04:00