Commit graph

610 commits

Author SHA1 Message Date
Anders Jenbo
4cdcff90db 🐛 Fix Zhar state not being set when triggered
Instead the first players golem was reset
2021-07-15 19:48:55 +02:00
Anders Jenbo
77b72da276 ♻️Use monster by reference when possible 2021-07-14 20:22:35 -07:00
ephphatha
a842d07dab Combine duplicated initialisation logic for quest book objects 2021-07-11 05:09:13 -07:00
ephphatha
cc3572af81 Update BookLever related functions to use Rectangle.
This is mainly to help isolate functionality in the hopes of adding a specialised object class for this type of object as suggested by @julealgon in https://github.com/diasurgical/devilutionX/pull/2344#discussion_r667415019

For example, AddSCambBook performs almost the same logic but uses var6 instead of var8 for the trigger condition/identifier.
2021-07-11 05:09:13 -07:00
ephphatha
e25d287ba9 Move SetObjMapRange to a member function
Due to the way this function is used it was easiest to also change ObjIndex to return a reference to the object instead of the index. Also added an explicit conversion from Size to Displacement to make one of the uses slightly cleaner to express.
2021-07-10 19:11:30 -07:00
ephphatha
ea63eecd17 Break out crux search logic from BreakCrux/SyncCrux
Really blanking on a good name for that function. Might not even be necessary given I think the BreakCrux use is effectively dead code, it could be rolled back into SyncCrux.
2021-07-10 16:40:12 -07:00
ephphatha
a1d4bdc98d Object by reference for BreakCrux
Some common code that searches for the crux object in the active objects list, can extract that into a dedicated function.
2021-07-10 16:40:12 -07:00
Andrew James
af60158274
Object by reference in SyncObjectAnimation functions (#2344) 2021-07-10 14:03:44 +02:00
Anders Jenbo
730c0750e7 Apply clang-tidy to code 2021-07-09 16:54:01 -07:00
ephphatha
74584bb02a Remove doorSetDirection temporary
Instead calling the function directly makes it easier to see common code patterns

DoorSet really only cares if the door opens to the left or the right

Can take a bool instead of the object type.
2021-07-10 01:03:24 +02:00
ephphatha
da4ae52886 Move objects_set_door_piece next to DoorSet
these two functions are always called together, can probably be combined or have a wrapper introduced

Move SyncL1Doors to near declarations of other SyncDoors functions
2021-07-10 01:03:24 +02:00
ephphatha
b0023be41e Remove unnecessary temporaries from SyncL3Doors
Simplify checks in SyncL3Doors

The function is only called with objects of type L3LDOOR or L3RDOOR so there's no real need to check again.

Take door by reference in SyncL3Doors

Removes one use of the Objects global.

Door by reference 2, SyncL2Doors

Simplify logic in SyncL2Doors to match L3Doors

Almost the same code, can probably be combined to a single function with appropriate parameters.

Use Point in DoorSet params

Use switch in DoorSet

Instead of a whole bunch of if statements where only one can be true

Replace object index with type in DoorSet

This function doesn't need any other object property. Still references the dPiece global unfortunately.

SyncL1Doors door by reference

Replace code that mutates a copy of door position with Direction

Inline if/else statement for L1LDOOR

Only difference is the value of the second parameter
2021-07-10 01:03:24 +02:00
ephphatha
36ff5578fd Refactor LoadMapObjects/LoadMapObjs to take Point instead of int x/y 2021-07-09 18:00:08 +02:00
ephphatha
3a517048f7 Refactor ObjIndex to take Point instead of int x/y
Also updated declaration of temporary/local variables to match
convention. This includes inlining int oi in LoadMapObjects as this
matches the way SetOBjMapRange is called in other areas.
2021-07-09 17:59:07 +02:00
ephphatha
19ae61811f Refactor AddObject to take Point instead of int x/y 2021-07-09 17:58:34 +02:00
ephphatha
e4b434b2ef Refactor SetupObject to use Point 2021-07-09 17:57:45 +02:00
ephphatha
288d691678 Refactor OperateShrineTown to use Point
Also added documentation about what the function does.
2021-07-09 17:57:01 +02:00
ephphatha
c2cf2f8b59 Refactor OperateShrineSparkling to use Point
Also added documentation about what the function does.
2021-07-09 17:56:27 +02:00
ephphatha
61a2cf9ac8 Refactor OperateShrineOily to use Point
Also added documentation about what the function does.
2021-07-09 17:55:57 +02:00
ephphatha
bc386a4701 Refactor OperateShrineDivine to use Point
Also added documentation about what the function does.
2021-07-09 17:55:20 +02:00
ephphatha
73cf62179c Refactor ObjSetMini to use Point 2021-07-09 18:52:51 +10:00
ephphatha
e668d215f2 Refactor objects_set_door_piece to use a Point param 2021-07-09 18:52:51 +10:00
ephphatha
cbe542c52e Refactor Add*Door functions to use more descriptive parameters 2021-07-09 18:52:50 +10:00
ephphatha
a3d155f552 Remove unnecessary temporaries from Obj_Light
This function can use Point member functions to perform the logic that determines when to show lights.
2021-07-09 18:52:50 +10:00
ephphatha
6f40f0dd88 Refactor ObjSetMicro to take a Point parameter 2021-07-09 18:52:50 +10:00
Anders Jenbo
903d4bd2e1 Scope all for loops
This caused 7 of the loops to be rewriteen using range by clang-tidy
2021-07-08 08:14:03 -07:00
Anders Jenbo
467b74dc06 Rename object globals 2021-07-08 02:01:14 -07:00
Anders Jenbo
9b8bf92575 Rename quest globals 2021-07-08 02:01:14 -07:00
Anders Jenbo
96bf75b502 Rename player globals 2021-07-08 02:01:14 -07:00
Anders Jenbo
dce78dde62 Rename lighting globals 2021-07-08 02:01:14 -07:00
Anders Jenbo
c8870dbd1f Rename item globals 2021-07-08 02:01:14 -07:00
Anders Jenbo
07ad083fda Rename monster globals 2021-07-08 02:01:14 -07:00
Vladimir Olteanu
d969672895 Check for negative random values in tear fountain logic 2021-07-05 17:11:54 -07:00
Anders Jenbo
56d3b5d710 clang-tidy/Android Stuidio cleanups 5 2021-07-05 13:14:47 -07:00
Vladimir Olteanu
04751418e0 Refactor tear fountain logic; remove GenerateRnd loop 2021-07-05 12:23:10 -07:00
ephphatha
08ae390643 Add explicit casts for some implicit conversions
Some of these were triggering multiple warnings due to casts applied at times which forced potentially truncating operations.
2021-07-05 08:52:05 -07:00
Anders Jenbo
bc0d1f7ac0 clang-tidy/Android Stuidio cleanups 3 2021-07-04 16:09:32 -07:00
Anders Jenbo
cb564a2d54 Clean up A-D 2021-07-04 05:25:37 -07:00
Anders Jenbo
a7c7fa0030 Fully apply clang-tidy/format to all files 2021-07-03 16:41:43 -07:00
Anders Jenbo
ecea12fc15 Clang-tidy: ParameterCase 2021-07-03 15:46:39 -07:00
Anders Jenbo
a350fb0b15 Clang-tidy: FunctionCase part 1 2021-07-03 03:45:33 +02:00
Anders Jenbo
4cd916a085 Clang-tidy: EnumConstantCase 2021-07-03 02:49:14 +02:00
Anders Jenbo
7e737cfa96 Merge remote-tracking branch 'refs/remotes/devilution/master' 2021-07-03 01:44:45 +02:00
Anders Jenbo
129342d07a Clang-tidy: GlobalConstantCase 2021-07-02 22:56:56 +02:00
Anders Jenbo
d9e0658643 Clang-tidy: basic naming 2021-07-02 22:55:01 +02:00
Anders Jenbo
d95a99d9a4 Clean up objects var init 2021-07-02 06:30:05 -07:00
qndel
373f1db22e
If cleanup + bugfixes (#2273) 2021-07-01 18:32:25 +02:00
Juliano Leal Goncalves
cbb84199c2 ♻️ Replace Point addition with 'Point + Displacement' 2021-06-28 20:37:44 -07:00
ephphatha
357f6f1dc3 Move RNG functions to their own header/source files 2021-06-27 03:09:41 -07:00
Anders Jenbo
bf221f4322 Clang-tidy: readability-simplify-boolean-expr 2021-06-26 23:12:22 +02:00