On SDKs which use protobufs, the engine has objects compiled against a specific
version of protobuf. Normally this is fine, we take care on Linux to use the
same C++ ABI. On macOS however, we use libc++ to enable C++11 functionality,
whereas the protobuf library has been compiled with libstc++. These ABIs are
not compatible.
To address the problem, we introduce PbHandle. PbHandle is a wrapper around
protobuf::Message with two added pieces of state: whether or not the handle
"owns" the message (and can free it in its destructor), and whether or not
the handle was created by the engine (private) or created by SourceMod
(local).
Whenever we transfer a protobuf::Message pointer to SourceMod, we must take
care to convert it to a Local version first. Whenever we transfer a protobuf
pointer to the engine, we must convert it to a Private handle.
For platforms with no ABI differences (almost all of them), the handle is a
no-op. The private and local localities are compatible and no translation
takes place.
On macOS, CS:GO does require translation. SourceMod loads a tiny shim
library that contains a copy of the protobuf sources compiled against the
game's ABI. It then provides serialization and deserialization methods.
SourceMod must not interact with the game's protobuf objects without first
going through this proxy library.
Note that PbHandle is not quite like unique_ptr. It can be converted into a
PbHandle that does not destroy the underlying object. This is mainly because
UserMessages.cpp has rather complex state, so it is useful to track locality
without destroying an object. An unowned PbHandle must not outlive the
owning PbHandle.
This patch removes almost all of the existing platform-specific
ThreadSupport code, as well as code derived from it. It is now
implemented on top of C++11 threads and is much simpler.
This is the first inclusion of STL in SourceMod. Mac and Windows are
allowed to dynamically link to their respective implementations. On
Linux, libstdc++ is statically linked, except in the cases where it was
already dynamically linked (csgo, blade).
IEventSignal has been retained because sourcemod-curl-extension relies
on it. As written, it is impossible to use as a condition variable,
because the caller does not have access to the underlying mutex. There
is no way to make this API safe or non-racy, so extensions relying on
it should switch to C++11 threads.
ThreadWorker is now pared down and does not interact or inherit from
BaseWorker in any way. Basic functionality has been tested. Since it is
not used anywhere in SourceMod, or seemingly in any repository on
GitHub, it's unclear whether it should even exist. But it has been
tested in this patch.
This change bumps the minimum macOS version to OS X 10.7, and the
minimum C++ standard level to C++14.
* Fix timelimit not correct for Black Mesa
Black Mesa is particular and use timelimit in seconds instead of minutes
* Update TimerSys.cpp
* Update TimerSys.cpp
* Update TimerSys.cpp
* Update TimerSys.cpp
The allocation size was still updated to the bigger size even if memory allocation failed. Trying to write to the supposedly available new space would overflow the heap and crash. Fixes#1233
* Fixed memory leak
When a pack was cleared or destroyed the String and Raw types could cause memory leaks. This happens when "position" is sitting at the end of the vector and can never get past the "if (pos >= elements.length())" statement. This means there is a memory leak in any plugin that clears/destroys a pack with strings and doesn't set the position to length-1 or less beforehand.
* datapack: Fix delete op on CDataPackType::Raw.
Co-authored-by: Kyle Sanderson <kyle.leet@gmail.com>
* DarkM: build-fix for engine msg caching
* style + promote ptr casting to uintptr_t.
* sync type to uintptr_t in pm.h
* return of the uint32_t
* update header.
* oh, right, unsigned int...
* Avoid losing console messages.
Buffers up to 16k bytes of SVC_Print if buffer would overflow, then sends chunks every frame.
Sends up to 2048 bytes per frame and does not split messages.
* UNTESTED! Switch to ke::LinkedList<ke::AString> for PrintfBuffer.
Switch from OnGameFrame to FramAction.
Fix compiling on Episode1 by essentially disabling the feature.
* UNTESTED! Cleanup on disconnect, passthrough for >= 2048 msgs
* try reference for CPlayer.
* fix
* remove m_PrintfStop
* remove m_PrintfStop
* ensure empty queue when netchan drops
* flip to serials.
* serials
* style
* Update PlayerManager.cpp
* lift consts to header.
* remove local const references
* ep1 static const
* flip to queue - fix serial on resched.
* Update PlayerManager.h
* Update PlayerManager.cpp
* Update PlayerManager.h
* am-deque.h
Co-authored-by: Kyle Sanderson <kyle.leet@gmail.com>
* Add natives to work with 64 bit Protobuf values
* Fix linux build
* FIX alignment requirements
* FIX alignment requirements V2
* Remove legacy API
* Inattention
When lookup of a more specialized entry in the maplists.cfg failed, it wouldn't fallback to the "default" section, but just try to parse the same section again.
* Change lookup strategy for SQL_CheckConfig
* Ensure db conf lookup failures default to ..default
* Revert "Ensure db conf lookup failures default to ..default"
This reverts commit 03dc703daeeeadaa134e2160bf2c7cd812402758.
This simplifies non-sdk build scripts by removing their loops over SM.archs. Instead the top-level
build script will re-evaluate them for each architecture.
This doesn't break any extensions NOT using IDataPack, and we do not know of any that are.
* The extension storage utility of this interface has been broken for the last 9 months, with ISourceMod::CreateDataPack being disabled.
* The plugin interop utility of this interface (its stated purpose) has been broken for the last 11+ years, with ISourceMod::GetDataPackHandleType being disabled.
I imagine it only survived the first cleanup 11 years ago because CSS:DM was using it internally, which it has now been migrated away from.
Compiled all the included extensions without changes (API compat), and loaded extensions build pre-change without issue (ABI compat).
* Match old DataPack behavior when overwriting data
* Make RemoveItem more flexible
* Ditch implied RemoveItem behavior & asher fixes
* KyleS nits - but fixed before he says them
* Add back implicit behavior
* Update CDataPack.cpp
Committing to the spec.
* Update CDataPack.h
* fixup removing last item if explicitly requested
* Fix logic for accepting pack pos, rather than index
* Fixup IsReadable
* headache is over now
* Make mac/win lookups lowercase'd
* Revert #709 & 81042cc
* Adjust HashPolicy implementation across sourcemod
Basically, in order to implement our own (actual) hash policy in
`PluginSys.h`, we needed to remove the blanket implementation of `hash`
that was used before. Now, each policy must implement `hash` along with
`matches` in order to be used with `NameHashSet`. While this does force
us to change every implementation of policies across the entirety of
sourcemod, it allows core to use flexible implementations of `hash`.
* Remove logic duplication
* Improve lowercase checks
* Add profiler methodmap
* No tag mismatches here
thanks pm
* Lets fix some documentation while we're here.
* Use proper methodmap documentation style
Across sm we use `//` for methodmap docs, so lets just keep this consistent
* Create DatabaseConfBuilder & remove locking
* Remove all refcounting
This is part 1/n in regards to this PR's rework
* Move db conf lookup out of RunThreadPart
* Return default configuration for failed lookups
* RefPtr members & stop leaks
* fix uint comparison warning
`ShowActivity` and related functions are used to inform all clients about the usage of admin commands (such as bans or mutes). These messages are not sent to any fake clients, however they _should_ be sent to SourceTV/GOTV fake clients because messages they receive are actually visible to broadcast viewers and in demos recorded with `tv_record`.
Player chat messages as well as SM functions like `PrintToChat`/`PrintToChatAll` broadcast to TV clients, but `ShowActivity` does not.
This adds support for platform specific custom key values in the `Keys` section in game config files. Now you can have different values for the same key per platform.
Previously you could only add general key values in gamedata files that were the same on all platforms like
```
"Keys"
{
"key" "value"
}
```
This patch allows you to set the value per platform in a subsection like
```
"Keys"
{
"key"
{
"windows" "value1"
"linux" "value2"
"mac" "value3"
}
}
```
Looking up the `key` will return the value matching the host platform.
* Migrate CDataPack from a Cassette Tape.
Tested-By: Headline22.
* Remove last IsReadable param pass.
* populate len still if CDataPack::ReadString is unreadable or the wrong type.
* Fyren Fixes(TM)(R)(C).
* Deprecate IDataPack.
* Create FrameIterator type
This commit adds the FrameIterator type to core sm along with a few
methods around getting the information for each frame.
* Fix incorrect documentation
[skip ci]
* Implement KyleS's Changes
* A nit
Allows for the last "read" offset for an Address to instead be "offset", which doesn't deref the addr pointer after applying the offset
Shortens the necessary coding to get a particular Address inside a function (old: store offset in a separate GameConf Offsets entry, apply the offset to the Address in SP)