231 Commits

Author SHA1 Message Date
yvt
b9a5d80f7b
Use Handle::New to construct T <: RefCountedObject
Unless `T::T(Args...)` is inaccessible from `Handle::New`, in which case
`Handle::Handle{new T(args...), false}` should be used.
2019-07-20 17:01:04 +09:00
yvt
830db57c01
Require rvalue for Handle::Unmanage 2019-07-20 16:38:21 +09:00
yvt
6e262ea6ec
Add stmp::make_unique
This template function is a polyfill of `std::make_unique`, which is
unavailable in GCC 4.9 (should we even be supporting this old thing?).
2019-07-20 16:17:10 +09:00
yvt
60fd3191c5
Remove Handle::operator T*(), discouraging conversion to raw pointers
It was replaced by `Handle::GetPointerOrNull()`. Every use of
`GetPointerOrNull` should be reviewed. Some of them were already removed.
2019-07-20 15:47:42 +09:00
yvt
6517338dab
Delete RefCountedObject's copy constructor 2019-07-20 14:18:48 +09:00
yvt
e6227b3361
Update IRenderer for null safety and safe memory management 2019-07-20 13:48:49 +09:00
yvt
464b88a23b
Fix optional::operator= 2019-07-20 13:42:34 +09:00
yvt
9e770cc040
Update the rules for RefCountedObject 2019-07-20 13:25:35 +09:00
yvt
a44a900c62
Fix Handle::Handle(T&) 2019-07-20 12:36:11 +09:00
yvt
8cdb086bb1
Add implicit casts between Handle<T> and stmp::optional<T &> 2019-07-20 12:26:44 +09:00
yvt
9038c7e135
Update the rules for RefCountedObject 2019-07-20 12:25:58 +09:00
yvt
fae85af23d
Make stmp::optional::operator= behave more like std::optional
This means the inner type's `operator=` is used whenever possible,
instead of using `T::T(const T&)` or `T::T(T&&)` all the time.
2019-07-18 16:12:44 +09:00
yvt
5f7dde6a96
Update and clarify the rules for RefCountedObject 2019-07-18 15:54:40 +09:00
yvt
5db97f7f10
clang-format 2019-07-17 00:31:22 +09:00
yvt
7c3a39e639
Modernize
- Replaced raw pointers with references or smart pointers. Nullable
  references are represented by `stmp::optional<const T&>`. (There are
  many raw pointers still remaining. They should be replaced at some
  point.)
- Added class template specializations `stmp::optional<T &>` and
  `stmp::optional<const T&>`.
- Fixed `stmp::optional`'s various behaviors
- `World::{players, playerPersistents}` are now `std::array`.
- More uses of `stmp::optional` to clarify the semantics
- Renamed `PlayerThrownGrenade` to `PlayerThrewGrenade`
- Replaced old-style `for` loops with range based ones
- Deleted `Player`'s default constructors and `operator =`
- Deleted `TCGameMode`'s default constructor and `operator =`
- Deleted `CTFGameMode`'s default constructor and `operator =`
- Replaced `static_cast` with `dynamic_cast` for down-casting
- `RefCountedObject::operator*()` no longer requires non-constness to
  return `T &`.
- Replaced the uses of `std::vector::operator[]` with `std::vector::at`
  for bounds checking.
- Made some methods of `GameMap` `const`.
- Added some null checks.
2019-07-17 00:31:00 +09:00
yvt
3c90eedfb8 Add Handle::operator== 2019-07-16 01:18:26 +09:00
yvt
07cdbf9d1d
Add some functions related to stmp::optional 2019-07-16 01:18:09 +09:00
yvt
008c687e83
Raise the buffer size limit of BoundedLogBuffer 2019-07-14 23:22:20 +09:00
yvt
e4efc8b5fc
Autocomplete config variables 2019-07-14 19:15:30 +09:00
yvt
93cccdecf9
Add View::AutocompleteCommandName 2019-07-14 18:29:50 +09:00
yvt
6b415aa7d4
Redirect SPLog to the console window 2019-07-14 16:02:07 +09:00
David Carlier
6ef18bd0cd Little code changes proposal.
Modern C++ stricter with member initialisation order.
Destructor possibly throwing exception through assertions.
In debug mode, pretty important memory leak with zip archives.
2019-05-26 07:18:39 +01:00
yvt
4e9370e8b4
Fix forgetting to unlock a recursive_mutex before deleting 2019-05-26 00:55:54 +09:00
yvt
c910bd4846
Remove Mutex, replacing their uses with std::{mutex, recursive_mutex} 2019-05-25 15:00:32 +09:00
yvt
76908188ab
Fix indentation 2019-05-25 14:32:52 +09:00
yvt
5e0cb27a4d
Add VoxelModelLoader
This new loader allows additional transformation on voxel models, e.g.,
setting a new origin point and replacing the material ID of all voxels,
based on a metadata file placed next to KV6 files.
2019-05-25 14:29:14 +09:00
yvt
6a39343daa
Introduce the concept of voxel material ID 2019-05-25 13:19:48 +09:00
yvt
a17a8f7b16
Fix to build with GCC 4.9 2019-05-19 17:14:51 +09:00
yvt
97ed5d46ad
Fix several small issues
- `GameMapLoader` did not start the decoding thread.
- `StreamHandle::operator=` caused SEGV for null handles.
- `PipeReader` prematurely stopped outputting data.
2019-05-19 16:13:21 +09:00
yvt
1a2287201d
Add GameMapLoader 2019-05-19 15:51:40 +09:00
yvt
10fc7da79d
Add StreamHandle::operator bool 2019-05-19 14:53:32 +09:00
yvt
a8b50e9a69
Add CreatePipeStream 2019-05-19 14:41:54 +09:00
yvt
40037ecb34 Add RandomAccessAdaptor::Prefetch 2019-05-19 13:12:16 +09:00
yvt
1997fec9a6 Add SPADES_MARK_FUNCTION to RandomAccessAdaptor 2019-05-19 13:09:55 +09:00
yvt
c4caf4c630 Add RandomAccessAdaptor::Read 2019-05-19 13:08:38 +09:00
yvt
894d8fbec4 Add SPADES_MARK_FUNCTION to RandomAccessAdaptor 2019-05-19 13:05:32 +09:00
yvt
024c8aa7ce Fix "memcpy is not a member of std" 2019-05-19 01:08:51 +09:00
yvt
b9426fd438 Add RandomAccessAdapter
It will be used to aid the implementation of the improved map loader.
2019-05-19 00:58:32 +09:00
yvt
6426247f09 Use C++11 atomics in place of AngelScript's implementation
AngelScript's implementation uses now-deprecated `OSAtomicIncrement32`
and generates compiler warnings.
2018-12-31 21:57:11 +09:00
yvt
3cd581260a Fix a bug causing the program not to start
This bug was introduced in ac4799abafbeb1d44d1b7166913406cd3a46b560.

This bug apparently only affected MSVC since the evaluation order of function
call parameters respect to other parameters is unspecified by the C++
specification.

Fixes #785.
2018-10-31 16:16:51 +09:00
yvt
c50906d16b Fix to build with GCC 4.9 2018-10-27 18:19:38 +09:00
yvt
ea0088ddd4 Explicitly delete a reference to SDL surface when a window is closed
This issue was identified by #775. (Hopefully) fixes #779.
2018-10-13 16:09:15 +09:00
yvt
6a6e771478 Add utilities and static checks to Handle 2018-10-13 16:07:24 +09:00
yvt
5dd26e3ce0 Use SPUnreachable() in place of SPAssert(false) 2018-10-13 16:07:04 +09:00
yvt
cfb972f944 Improve code quality
- Overriding methods are clearly indicated with `override` keywords
- Remove redundant `virtual` keywords from destructors of subclasses
- Introduce `SPUnsupported()`, replacing most uses of
  `SPNotImplemented()`, which now serves as a dynamic "TODO" marker
2018-10-13 14:43:49 +09:00
YVT
49f0bbe6f4
Merge pull request #774 from yvt/patch-rng
Improve/fix random number generation
2018-10-08 14:39:38 +09:00
yvt
5e03526fe4 Fix to compile with MSVC 2017 2018-10-08 14:35:10 +09:00
yvt
888253a691 Remove an unnecessary constructor of stmp::optional 2018-10-08 01:22:29 +09:00
yvt
5376c1c0c4 Get rid of the non-standard typeof operator 2018-09-18 22:33:48 +09:00
yvt
30e49b68aa Implement thread-local random number generator 2018-09-18 22:18:54 +09:00