218 Commits
Author SHA1 Message Date
obligaron bd3d17975c Fix MSVC SDL1 warnings 2023-12-22 17:03:01 +01:00
obligaron 95205294e8 Fix MSVC x86 warnings 2023-12-22 17:03:01 +01:00
staphen c4792be763 Remove invalid items after loading heroitem data 2023-11-19 23:48:21 +01:00
Gleb Mazovetskiy 0d19c1b773 Slightly optimize loading same-sprite monsters
For monsters with the same sprite, load the sprite from the file system only once.

Example:

```
VERBOSE: Loaded monster graphics: falspear\phall   452 KiB   x1
VERBOSE: Loaded monster graphics: skelbow\sklbw    618 KiB   x1
VERBOSE: Loaded monster graphics: skelsd\sklsr     610 KiB   x1
VERBOSE: Loaded monster graphics: goatbow\goatb    832 KiB   x1
VERBOSE: Loaded monster graphics: bat\bat          282 KiB   x2 <-- here we only load the sprite once
VERBOSE: Loaded monster graphics: rhino\rhino     1306 KiB   x1
VERBOSE: Loaded monster graphics: golem\golem      298 KiB   x1
VERBOSE:  Total monster graphics:                 4401 KiB 4684 KiB
```

Here, the bat sprite will be loaded from the MPQ only once.
For the second sprite, we simply clone the first sprite before applying TRNs.

This also reduces the size of `MonsterData` from 88 bytes to 80.

When we migrate monster data to a TSV, the sprite IDs can be generated automatically at load time.
2023-11-10 06:01:40 +00:00
ephphatha 28fd553266 Use HeroClass in UI functions 2023-09-20 05:49:54 +02:00
Gleb Mazovetskiy e090c8bf31 Extract some player attributes to data files 2023-09-17 14:49:12 +01:00
Gleb Mazovetskiy 70ff515f48 Stream demo messages
This entirely eliminates the demo memory overhead.
2023-09-02 20:54:24 +01:00
Gleb Mazovetskiy 5355146d51 Use structured bindings 2023-08-29 12:56:49 +01:00
ephphatha da76e131e4 Add getter/setter for character levels to ensure _pNextExper stays synced 2023-08-24 05:46:44 +02:00
Gleb Mazovetskiy ebe8c6e576 Add tl::expected and use it in ParseInt
`std::expected` has been standardized for C++23.
2023-08-19 17:13:54 +09:00
Gleb Mazovetskiy 8c1a847f41 Remove utils/stdcompat/string_view.hpp 2023-08-14 09:59:14 +01:00
Gleb Mazovetskiy 62d067b653 Remove utils/stdcompat/abs.hpp 2023-08-14 01:54:29 +01:00
Gleb Mazovetskiy 74755c8be7 Remove utils/stdcompat/cstddef.hpp 2023-08-14 01:54:29 +01:00
Gleb MazovetskiyandAndrew James 53db86ee9a Use std::from_chars instead of std::stoi
Adds a `ParseInt` function which uses `std::from_chars`.

From `std::from_chars` documentation:
> Unlike other parsing functions in C++ and C libraries,
> std::from_chars is locale-independent, non-allocating, and non-throwing.

Co-authored-by: Andrew James <[email protected]>
2023-08-13 21:43:53 +02:00
qndel 728b632960 fix typos 2023-08-12 18:10:22 +02:00
Anders Jenbo 63277a842d Clean up player packing 2023-06-24 04:18:14 +02:00
Anders Jenbo efa51993e3 Split network player sync and hero save file 2023-06-24 04:18:14 +02:00
Gleb Mazovetskiy 4fa3732526 Add missing <cstdint> includes
Done with the following script:

```ruby
Dir["Source/**/*.{h,c,cc,cpp,hpp}"].each do |path|
  v = File.read(path)
  next if !v.include?("uint32_t") || v.include?("cstdint")

  lines = v.lines
  line_num = if lines[2].start_with?(" *")
    lines.index { |l| l.start_with?(" */") } + 3
  else
    3
  end

  lines.insert(line_num, "#include <cstdint>\n")

  File.write(path, lines.join(""))
end
```

then fixed-up manually
2023-05-10 13:50:12 +01:00
Gleb Mazovetskiy 957bd03b98 Remove FMT_COMPILE in "cold" places
Removes most `FMT_COMPILE` calls.
`FMT_COMPILE` results in better performance but larger code size.

Removes `FMT_COMPILE` calls for places that are called infrequently,
i.e. not on every frame.

RG-99 binary size reduced by ~4 KiB.
2023-03-12 19:29:35 +01:00
Gleb Mazovetskiy 1a1a282d9a Use C FILE instead of C++ streams throughout
Reduces binary size by ~2 KiB and may improve compatibility with oddball
systems (e.g. PS2).
2023-02-15 18:15:07 +00:00
Eric Robinson f75f66d54b Add playerdat (#5763) 2023-02-10 12:56:28 +00:00
Gleb Mazovetskiy 6d274c9547 UNPACKED_SAVES: Saves without MPQs
Reduces rg99 binary size by ~70 KiB.
2023-01-18 23:40:30 +00:00
Stephen C. Wills c91702ffbc Don't use MyPlayer in SaveHotkeys() (#5292) 2022-08-26 23:53:38 +02:00
Gleb Mazovetskiy 3b357f3936 CMake: An option to disable demomode support
Useful for targets with limited RAM.
Reduces RG99 binary size by 8 KiB.
2022-08-10 21:24:45 +02:00
obligaron 385627e95b Copy save file when creating reference or comparison save game 2022-08-03 09:06:56 +02:00
obligaron 2c7e886c85 Add detail log info to CompareSaves 2022-08-02 02:12:36 +02:00
Gleb Mazovetskiy 7c0b72abc0 Improve demo test error message
Example:

```
file "game" is different at byte 54251:
Expected: ... 00 00 00 00 00 00 00 00 30 00 00 00 50 00 00 00 ...
  Actual: ... FF FF FF FF 00 00 00 00 30 00 00 00 50 00 00 00 ...
```
2022-07-26 01:20:06 +02:00
Gleb Mazovetskiy 04c3d85179 Remove MAX_PATH
Rather than using the Windows-like `MAX_PATH`, what we really want is 2
things:

1. Maximum path of a file in an MPQ. This is now `MaxMpqPathSize`.
2. Max size for the known monster paths. This is now 64 for sounds and
   TRNs, which is more than enough (picked arbitrarily).
2022-07-16 11:14:16 +01:00
Anders Jenbo 2d21fc372e Remove more miniwin code 2022-07-10 21:13:39 +02:00
Gleb Mazovetskiy 197e1180b2 Add StrCat and StrAppend
Adds simple string / integer concatenation functions.

Many of the uses of `fmt::format` are simply concatenation
of a few strings and integers.

`StrCat` is an easier-to-read alternative to such uses of `fmt`.
2022-07-10 06:14:58 +02:00
Gleb Mazovetskiy 4063afb792 Xbox NXDK platform 2022-07-09 18:50:53 +01:00
Mikołaj Piróg dda0b96ea5 Remove #defines in player.h and add constexpr where applicable (#4896)
* Change defines to constexpr int in player.h

* Add const or constexpr to player.h/cpp where applicable

* Update tests with changed names of player constatns

* remove unecessary variable
2022-07-05 17:25:23 +02:00
Gleb Mazovetskiy 3178dd5158 Replace most uses of sprintf with fmt (#4837) 2022-07-01 17:02:56 +02:00
Anders Jenbo 54598e2a8f CreatePlayer by reference 2022-06-28 16:51:45 +02:00
obligaron 7a27fcd249 Fix pfile_compare_hero_demo: Close MpqWriter before reading (for comparsion) 2022-06-25 17:53:32 +02:00
obligaron f0b3d9cb5b pfile: remove savePrefix global 2022-06-16 09:43:34 +02:00
obligaron 7afe7d2a70 Save Methods in loadsave gets MpqWriter passed 2022-06-16 09:43:34 +02:00
Gleb Mazovetskiy 779ccaca17 Overhaul translation fetching
1. Do not modify the map after loading. Instead, return string views
   (guaranteed to be null-terminated) from look up functions and return
   the key directly if not found.
2. Use an `unorded_map` instead of `map` where available (C++20).
   Saves a bit of RAM (~50 KiB) and improves lookup performance.
2022-06-14 12:46:36 +01:00
obligaron 1608219b39 Timedemo: Create reference save game and allow comparing of reference save game with actual timedemo save game 2022-06-04 21:15:47 +02:00
qndel 354e329644 Players[MyPlayerId] -> MyPlayer 2022-05-31 05:35:52 +02:00
obligaron 9c0960589e clearTables when closing stash mpq 2022-04-07 23:36:29 +02:00
Anders Jenbo 1409e604f5 Reduce string conversions 2022-03-20 11:04:15 +01:00
Anders Jenbo a48f89007d Implement stash 2022-03-18 06:01:53 +01:00
staphen b85485b8f3 Resolve game crash when syncing Diablo items in Hellfire games 2022-01-17 00:31:27 +01:00
Anders Jenbo 799f1763af Performce UTF8 aware limited string copies 2021-11-22 03:28:51 +01:00
Gleb Mazovetskiy 720d210d95 utils/mpq* -> mpq/* 2021-11-17 11:49:57 +01:00
Gleb Mazovetskiy 23406b6fc5 Replace mpqapi.h with the MpqWriter class
This is a cleanup, heading in the direction of allowing us to reuse
some of the code between reading and writing MPQs.
2021-11-10 01:41:11 +00:00
Gleb Mazovetskiy 3d308983a8 Migrate to libmpq
libmpq is a much simpler alternative to StormLib for reading MPQ archives.

We use our own fork of libmpq: https://github.com/diasurgical/libmpq

Impact:

* DevilutionX is now a lot more portable. Unlike StormLib, libmpq only
  needs platform-specific code for Windows.
* Locks around file access **removed** (instead we duplicate the file descriptor for streamed audio only).
* RAM usage is **300 KiB** lower than StormLib.
* Stripped release linux_x86_64 binary is **32 KiB** smaller.
* Amiga build now hangs instead of crashing.
2021-11-06 23:51:42 +00:00
Anders Jenbo b77686213a 🐛 Correctly wipe temp data from saves
Fixes #3167
2021-10-26 16:51:56 +02:00
Anders Jenbo eb3012cc0d Reset player object before unpacking hero data 2021-10-12 04:56:30 +02:00