Commit Graph

51 Commits

Author SHA1 Message Date
ALONSO Laurent
64f206b5be universe.cpp: correct a memory problem with is_road... 2023-01-21 20:55:46 -05:00
d83139eaa0 Implement exp_adj
The original source had remnants of a PC-specific experience gain adjustment, which
appeared to be intended as a debugging aid.

I've restored and implemented it, and used it on the debug party.
It doesn't necessary need to be relegated to only a debug feature, but for now, that's
good enough.
2023-01-21 18:32:50 -05:00
992cbdb22c Delete cCurTown::difficulty
It seemed like it was intended as a mirror of cTown::difficulty, yet there didn't seem to
be anything that ever wrote to it.
So I just made everything use cTown::difficulty directly instead.
2023-01-21 18:10:58 -05:00
4c6296612d Add a function to wrap percentage calculations
This should help avoid issues from integer overflow (which is technically undefined behaviour)
while also allowing such issues to be addressed centrally if they still exist.
2023-01-21 17:53:06 -05:00
d7dcf24644 Fix calling restore_sp to drain SP from an affect special node
This also adds an Allow Resist flag to determine whether the target's
Mage Spells or Priest Spells skill can reduce the amount drained.

Thanks to @fosnola for spotting this issue.
2023-01-21 17:52:23 -05:00
c27403b3d7 expl is never used anywhere, so delete it
Note: This will definitely break saved games
2023-01-21 12:17:41 -05:00
5c6e34b5de Zero stuff done flags in the constructor
Thanks to @fosnola for spotting this
2023-01-21 11:10:01 -05:00
dc716fa5e6 Don't store inactive timers in the saved game
Thanks to @fosnola for spotting this.
2023-01-21 10:28:16 -05:00
a430abbd50 Fix fields array not matching the size of the town
The fields array was fixed at 64x64, which is fine for all towns
supported in legacy BoE.

However, we intend to support even larger towns in the future,
and also it seems silly to hold so much extra space for a smaller town.

So now, the fields array is a 2D vector that matches the size of the terrain vector.
The setup array is similarly a list of 2D vectors.

This radically changes the format used to store the setup array in a saved game.
Older saves won't crash the game, but fields will be messed up or missing.
Resetting towns is recommended.
2023-01-21 00:47:35 -05:00
c7c8f3fa77 Sanity pass of saved game format
This adds several fields to the saved game format that were simply missing.
- Monster boolean flags (for summons)
- Some missing monster ability details (for summons)
- Special on talk (for creatures)
- Max SP and morale (for creatures)
- Source scenario (for encounter notes)

It also changes the default resist to 0 instead of 100, meaning that
resistances will be saved almost always, but should be loaded correctly.

The target location is no longer saved for creatures.
There was already code that nulled it out after loading,
so now that just happens during loading instead.

The town active flags (belt_present and quickfire_present)
are now set during loading instead of after loading.

This changes the save format, so there will be minor incompatibilities.
In particular, monster health won't be loaded correctly from older saves.
2023-01-20 23:51:35 -05:00
642a863594 Delete a redundant member (it's inherited from iLiving) 2023-01-20 09:55:44 -05:00
5cd2ced8c2 Add cParty::is_in_scenario() 2023-01-20 09:07:24 -05:00
1bf079af5e Fix some missing initializers
Spotted by @fosnola
2023-01-18 21:16:33 -05:00
b422cdf429 Add some terrain bounds checking and some named constants 2023-01-18 20:08:56 -05:00
2492610ec7 Reading and writing saved games now uses the new tagfile system.
This should avoid any format inconsistencies, like missing newlines and the like.
Although a basic save and load works, there may still be some issues with the format.
This probably renders older saved games incompatible.
The format is mostly the same, but there are a few small changes
in the name of making the format more uniform.
2023-01-18 00:54:39 -05:00
8872f1aa25 Stop storing players as bare pointers - use unique_ptr instead
Should fix some potential memory leaks that were caught by static analysis
2023-01-12 21:26:08 -05:00
ALONSO Laurent
fa15177978 save: try to save the magic_ptrs correctly... 2023-01-06 20:04:02 -05:00
ALONSO Laurent
db91ea9770 reset the scried monsters' list when we enter a scenario... 2023-01-06 20:04:01 -05:00
ALONSO Laurent
d1cb01e263 try to save correctly SHOPSTOCK... 2023-01-06 19:28:33 -05:00
ALONSO Laurent
eea6166b11 party.cpp: retrieve correctly the notes 2023-01-06 13:55:21 -05:00
cb73719af3 Make item abil_data a bit more readable
A two-element array is an ugly thing to behold
2023-01-06 02:13:46 -05:00
261f46b0b5 This avoids an extra iteration that can cause test failures 2023-01-05 19:52:30 -05:00
5b2561d034 Disable header maps in Xcode 12 2022-07-12 20:35:41 -04:00
x-qq
55a105a0f6 make the game buildable on linux (#283)
- Scons -> python3
- include issues
2022-03-13 15:38:22 -04:00
7b93726383 Replace 4-character constants with enums
This covers only the places where they were used to indicate
a preset selection in constructors.

The usage in qdpict where they're actually passed to the Resource Manager,
as well as the 4-character constants representing file types and creator
codes, are still present.
2020-02-21 00:16:58 -05:00
x-qq
d314432664 fix uninitialized debug flags in universe 2020-02-11 15:34:29 +02:00
86d2574aed Some refactor of special node system
- Context type (town/out/scen) is now an enum
- Don't expose internals in the header
- Use a state struct to pass things around through the system
- Fix special AFFECT_DEADNESS case for default party selection
- Maybe other bits and pieces?
2020-02-02 19:12:45 -05:00
fa7158de03 Fix exportGraphics not checking previously-exported monsters
I'm actually not sure whether this is necessary,
but decided to err on the side of caution
(since check_item does the same thing).
2020-01-19 15:38:05 -05:00
cb8bf96832 Fix buffer overflow in exportGraphics 2020-01-19 15:38:05 -05:00
479cfb75f6 Fix improper loading order with saved games 2020-01-02 00:28:52 -05:00
b6aee36a0c Write hidden/visible state for EVERY town in the save file, even if it's equal to the scenario default
This should fix #197 for any new saves created after the fix.
2019-12-30 01:48:00 -05:00
6f96222c37 Remove the 30-item limit in shops 2019-12-02 01:16:34 -05:00
6ca89a66a9 Fix items being unequipped sometimes when an item is picked up 2019-11-24 20:28:53 -05:00
3302dd68b7 Move encumbrance calculation functions into cPlayer 2019-11-24 20:28:53 -05:00
4ad85936d3 Fix use of a static bitset to record whether items (in a dynamic vector) have been taken 2019-11-23 12:31:30 -05:00
9073063423 Merge branch 'merge_linux' of https://github.com/murlock/cboe 2018-03-03 17:52:59 -05:00
827e1b2a6b Fix crash when loading a saved game containing boats or horses 2018-02-18 17:33:12 -05:00
03c19fa7ec Use the new erase_completed_specials() function for towns too 2018-02-17 18:46:53 -05:00
Michael Bonfils
d940f2c39d Merge branch 'linux' into merge_linux 2018-02-08 20:36:46 +01:00
f3866861bb Fix inability to duel-wield
(thanks to Ir the Great for this patch)
2017-12-16 16:51:27 -05:00
b0d2ca8e23 Fix possible crash on exiting scenario
(thanks to Ir the Great for this patch)
2017-12-16 16:37:59 -05:00
9127e4a03f Enable building tests in MSVC 2013 2017-09-16 12:46:31 -04:00
9d86053817 Fix up MSVC project file for the major reorganization 2017-08-30 00:09:01 -04:00
7e7f3d2b81 Merge mac into windows 2017-08-27 23:37:37 -04:00
7987680bf4 Simplify some stuff with references 2017-04-15 02:04:11 -04:00
1f9615d185 Add an info structure for eItemType enum 2017-04-15 02:03:42 -04:00
c2ce2a2cd1 Split up the graphtool files 2017-04-14 15:43:07 -04:00
e57441f6a0 Consolidate active quest data into a single map 2017-04-14 11:38:06 -04:00
5b5b2af46f Remove custom erase_if function in favor of std::remove_if
It was originally added before I understood the correct way to use remove_if

As a side-effect, remove bad status now also removes forcecage and charm.
2017-04-14 11:37:27 -04:00
4baac518e9 Move stream operator declarations into the same file as their types 2017-04-14 01:07:21 -04:00