1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-06-09 17:30:43 +00:00
Commit Graph

291 Commits

Author SHA1 Message Date
gravestench
33368e5aa3
Lint cleanup funlen (#854)
* d2ui/button.go: refactored button state prerender to fix funlen lint error

* d2player/help/help.go: break up Load method to reduce complexity

* d2game/d2player/game_controls.go: refactored renderHUD method, fixed funlen lint error

* d2player/skilltree.go: fixed funlen lint error

* map_engine_test.go: fixed funlen lint error
2020-10-26 15:55:13 -07: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
0bd774aaa6
fixed some of the remaining funlen lint errors (#850)
* d2records/: suppressing function legnth lint errors for record loaders

* d2gamescreen/character_select.go: broke up OnLoad method to reduce complexity

* d2ui/button.go: suppressing funlen lint error, can't reduce function size
2020-10-26 04:39:10 -07:00
gravestench
1046fb6137
bugifx (#849) 2020-10-26 04:35:23 -07: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
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
060abdc3bd
removed globals, added nolint to tests that used globals (#843) 2020-10-25 21:06:00 -07:00
gravestench
359bcd6ef8
fixed all goimports lint errors (#842) 2020-10-25 20:55:46 -07:00
gravestench
13d5e1c4de
removed all 'lll' (line length) lint errors (#841) 2020-10-25 18:11:04 -07:00
gravestench
37235282e0
removed all 'deadcode' lint errors (#840) 2020-10-25 18:01:57 -07:00
gravestench
49c1985dcc
removed all 'structcheck' and 'unused' lint errors (#839) 2020-10-25 17:49:41 -07:00
gravestench
42a48fe03a
removed all 'whitespace' lint errors (#838) 2020-10-25 17:33:04 -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
6b5c2a1fc5
removed all 'govet' type lint errors (#834) 2020-10-25 16:50:13 -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
Julien Ganichot
8e957c17fe
fix(run/walk): changes invalid surface for toggled state (#816) 2020-10-25 15:12:55 -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
gravestench
18c9e85cbc
d2game/d2player/ lint error cleanup (#788)
* d2game/d2player/inventory.go: magic number lint cleanup

* d2game/d2player/mini_panel.go: magic number lint cleanup

* d2game/d2player/skill_select_panel.go: lint cleanup

* d2game/d2player/skilltree.go: removed all lint errors

* removed the rest of the magic number errors from d2game

* hotfix for bug i added in map engine test

* all magic numbers removed (excluding  mapgen)
2020-10-25 00:42:31 -07:00
presiyan-ivanov
c4b128ac2e
Handle casting summon skills and skills that have multiple missile references. Add background to skill select's skill hover tooltip. (#786)
Co-authored-by: Presiyan Ivanov <presiyan-ivanov@users.noreply.github.com>
2020-10-24 10:08:45 -04:00
gravestench
16a82442bb
removed a bunch of magic number lint errors (#785)
* removed magic numbers from d2ui/button.go

* removed a bunch of magic number lint errors
2020-10-23 09:00:51 -04:00
gravestench
2704a23289
removed magic numbers from d2ui/frame.go (#784) 2020-10-22 14:27:18 -07: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
209cc19c89
removed a lot of magic number lint errors (#781) 2020-10-22 10:02:32 -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
Thomas Christlieb
30b6f0cb4e
first stamina drain implementation (#778)
Bugs: 1. In D2 when Stamina is drained it does not regenerate until you completely stop
2. Stamina Bar does not get red when near the end
2020-10-21 23:25:53 -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
gravestench
7fb57a273b
hotfix for #768 (#769) 2020-10-10 23:31:12 -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
Thomas Christlieb
d78175b7b4
Player starts walking, and allow for CTRL-Key to toggle running while holding key (#762) 2020-10-07 16:12:56 -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
a5f9067248
replace satori/go.uuid with google/uuid (#747) 2020-09-23 13:30:15 -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
Gürkan Kaymak
ef0fbc0581
removed gui manager singleton in d2gui (#735) 2020-09-18 16:10:52 -04:00
Brendan Porter
d0410001de
adds close button and close button behavior (#731) 2020-09-15 23:37:08 -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
presiyan-ivanov
8a670d7482
Prevent player movement and casting if current spell cast is not fini… (#729)
* 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>
2020-09-14 14:49:31 -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