Leviathan game engine
Todo List
Page Events

List events that are recognizable by scripts here

Allow scripts to create data for Leviathan::Event objects

Page Getting started tutorial
Create tutorials
Page How the Leviathan VideoPlayer Works

Make sure the latest, working code is copied here

This is outdated as CEGUI is no longer used. Replace with an example of playing video on an Ogre material

Page Leviathan Connections

Add a test that verifies that the server can be the one to call Leviathan::Connection::Init first

Add data to the Connect request / response to allow connections with the master server.

Class Leviathan::AngelScriptTypeIDResolver< T >
This will entirely break if there can be multiple script executors in use
Member Leviathan::BindEntity (asIScriptEngine *engine)
Create a wrapper around NewtonBody which has reference counting
Member Leviathan::BindNamedVars (asIScriptEngine *engine)
make this safe to be passed to the script
Class Leviathan::CallableObject
Rewrite this to be cleaner with the event return codes
Member Leviathan::CallableObject::GetListenerNameFromType (EVENT_TYPE type)
Have a bi-directional map to speed up lookups
Class Leviathan::ConnectedPlayer
Add a kick method and use it in NetworkServerInterface::CloseDownServer
Member Leviathan::ConnectedPlayer::OnKicked (const std::string &reason)
Add the reason to the packet
Member Leviathan::Connection::_Resend (SentRequest &toresend)
Create Resend method that pools together many failed messages
Member Leviathan::Connection::CalculateNetworkPing (int packets, int allowedfails, std::function< void(int, int)> onsucceeded, std::function< void(PING_FAIL_REASON, int)> onfailed)
Check whether the packets should be send in a cluster or not (as they are currently sent in one go)
Member Leviathan::Connection::Connection (const std::string &hostname)
Add a option to game configuration for default port
Member Leviathan::Connection::ExtraAckCount
Implement this
Member Leviathan::Connection::GenerateFormatedAddressString () const
this could be cached
Member Leviathan::Connection::Init (NetworkHandler *owninghandler)
Make this async resolve the address
Member Leviathan::Connection::LastReceivedMessageNumbers
Implement a lower bound (under which everything is dropped) and make this smaller
Member Leviathan::Connection::LastUsedLocalID
Fix that
Member Leviathan::Connection::SendCloseConnectionPacket ()
Add a message parameter for the reason
Class Leviathan::CustomCommandHandler

Allow scripts to register these

Allow optional usage of an internal command table with descriptions etc.

Class Leviathan::DataBlock< DBlockT * >
Add support for move operators to this too
Class Leviathan::DataBlock< DBlockT >
Add move constructor and move assignment operators
Class Leviathan::Delegate
Allow unregistering callbacks
Member Leviathan::Delegate::Call (const NamedVars::pointer &values) const
Find a way to more efficiently pass known types or data that may not be stored (only copied)
Member Leviathan::Editor::Editor::ShownOnWindow
This needs some mechanism to detect when the window is closed and the editor should also close then
Class Leviathan::Engine
Reduce the amount of logging and mention thread safety on methods that ARE thread safe and add note to assume that everything else isn't
Member Leviathan::Engine::FocusOrOpenEditor ()
Closed editors need to report that they are closed in order to open one again
Member Leviathan::Engine::Invoke (const std::function< void()> &function)
Write a wrapper file that can be used for invoking without having to include this huge file
Member Leviathan::Engine::OpenEditorWindow (Window *useexistingwindow=nullptr)
Exit fullscreen mode if main window is in fullscreen mode
Member Leviathan::Engine::OpenNewWindow ()
Allow changing the parameters
Member Leviathan::Engine::Release (bool forced=false)
Add a thread that monitors if the thing gets stuck on a task
Member Leviathan::EventHandler::CallEvent (const GenericEvent::pointer &event)
Swap this with the function above to make this more efficient (and switch to using this)
Class Leviathan::GameModuleLoader
Module unloading needs some trick
Member Leviathan::GameModuleLoader::Load (const std::string &modulename, const char *requiredby)
Allow loading by relative path (right now must just have the exact module name)
Member Leviathan::GameWorld::CreateEntity ()
Make this have a per world counter
Member Leviathan::GameWorld::DestroyEntity (ObjectID id)
Make this less expensive
Member Leviathan::GameWorld::GetAddedFor (COMPONENT_TYPE type, std::vector< std::tuple< void *, ObjectID, ComponentTypeInfo >> &result)
Find a better way than having to have the component type specified here. This is only used by script node proxy, so this has to be somewhere for it to access
Member Leviathan::GameWorld::HandleEntityPacket (ResponseEntityUpdate &&message, Connection &connection)
If we receive an update after an entity is destroyed the message should not be queued
Member Leviathan::GameWorld::Render (int mspassed, int tick, int timeintick)
Allow script systems to specify their type
Member Leviathan::GameWorld::SetFog ()
Fix this for Ogre 2.1
Member Leviathan::GameWorld::SetWorldPhysicsFrozenState (bool frozen)
Synchronize this over the network
Member Leviathan::GameWorld::ShouldPlayerReceiveEntity (Position &atposition, Connection &connection)
Implement this
Member Leviathan::GeometryHelpers::CreateScreenSpaceQuad (const std::string &meshname, float x, float y, float width, float height)
Parameter to specify if shadow geometry is needed
Member Leviathan::GeometryHelpers::CreateXZPlane (const std::string &meshname, float width, float height)

Merge the shared code with CreateScreenSpaceQuad

This needs to be verified that this generates good geometry (currently crashes when recorded with RenderDoc)

Member Leviathan::GlobalCEFHandler::RegisterCustomJavaScriptQueryHandler (std::shared_ptr< GUI::JSAsyncCustom > ptr)
Add support for removing existing ones
Class Leviathan::GUI::CefApplication
It would be good style to split this into CefClientApp and renderer and other
Member Leviathan::GUI::CefApplication::OnRegisterCustomSchemes (CefRawPtr< CefSchemeRegistrar > registrar) override
Register custom schemes
Member Leviathan::GUI::CefApplication::OnRenderThreadCreated (CefRefPtr< CefListValue > extra_info) override
Should the custom extensions require static strings that would also be available in the render process? To reduce copying and converting between utf8 and utf16
Member Leviathan::GUI::CefApplication::StartListeningForEvent (JSNativeCoreAPI::JSListener *eventsinfo)
These should be moved to use SendProcessMessage to move all of this specific functionality out of this class
Class Leviathan::GUI::CefFileResourceHandler
This needs blocking against reading files outside the game/Data directory
Member Leviathan::GUI::GuiManager::GetTargetLayerForInput (INPUT_EVENT_TYPE type, int mousex, int mousey)
Add support for multiple views inside a window. And prefer the active input if this is a keypress
Member Leviathan::GUI::GuiManager::LoadGUIFile (const std::string &urlorpath, bool nochangelistener=false)
Make sure that loading a path with spaces in it works
Class Leviathan::GUI::JSAudioSourceInterceptor
Expose a destroy method to js as relying on garbage collecting doesn't seem that great
Class Leviathan::GUI::JSNamedVarsInterceptor
Change this to an interceptor to not have to call SetValue in AttachYourValues
Class Leviathan::GUI::JSNativeCoreAPI
Figure out if CEF actually runs multiple threads in the render process. This may not actually be the case so the lack of locking here might not cause issues. The lock was removed from here to not cause deadlocking, and because ThreadSafeRecursive didn't compile with visual studio while we are processing something else if that is true
Member Leviathan::GUI::Layer::InputFocused
This needs to be tracked per frame for CEF browsers. Not sure how that should be done
Member Leviathan::GUI::Layer::ScrollableElement
This needs to be tracked per frame for CEF browsers
Class Leviathan::GUI::VideoPlayer

Implement pausing and seeking

When Stop is called the OnPlaybackEnded should still be fired. If something was playing

Member Leviathan::GUI::VideoPlayer::OnPlayBackEnded
Should be renamed to OnPlaybackEnded
Member Leviathan::GUI::VideoPlayer::OnVideoDataLoaded ()
Rename to CreateOutputTexture
Class Leviathan::GUI::VideoPlayer::ReadAudioPacket
Allow reuse here to reduce memory allocations
Class Leviathan::GUI::VideoPlayerWidget
This is currenlty hardcoded to work with GuiManager::PlayCutscene if the plan for a custom GUI system is to go forward this needs to be generalized
Member Leviathan::GUI::VideoPlayerWidget::Stop ()
The player should be changed to call our callback when it is stopped
Class Leviathan::GUI::View

Split the process messages away from this into the places that actually sent them "JSNativeCoreAPI.cpp" to be clearer

If this is to be kept around rename this to CEFLayer

Member Leviathan::GUI::View::_HandleAudioSourceMessage (const CefRefPtr< CefProcessMessage > &message)
It would be quite good if this and HandleProcessMessage (the AudioSource part) could be moved to one file so that all the implementation for the proxy would be in the same place
Member Leviathan::GUI::View::AdditionalFrameSecurity
Allow configuring per frame
Member Leviathan::GUI::View::OnLoadEnd (CefRefPtr< CefBrowser > browser, CefRefPtr< CefFrame > frame, int httpStatusCode) override
Make that future multi Gui::View windows don't all get focus back
Member Leviathan::GUI::View::OnProcessMessageReceived (CefRefPtr< CefBrowser > browser, CefProcessId source_process, CefRefPtr< CefProcessMessage > message) override
check access level properly
Class Leviathan::GUI::WidgetLayer
This is currenlty hardcoded to work with GuiManager::PlayCutscene if the plan for a custom GUI system is to go forward this needs to be generalized
Allow this to not be a multiple of TICKSPEED or smaller than it
Member Leviathan::LAN
A proper lan detection
Class Leviathan::Logger
Allow logs that don't save to a file
Class Leviathan::NamedVariableList

Make this reference counted

Make all methods throw exceptions on invalid operations

Member Leviathan::NamedVariableList::SwitchValues (NamedVariableList &receiver, NamedVariableList &donator)
Rewrite this as a move operation
Class Leviathan::NamedVars
Make all methods throw exceptions on invalid operations
Member Leviathan::NamedVars::NamedVars (const std::string &datadump, LErrorReporter *errorreport)
Allow predefined values
Class Leviathan::NetworkCache
Make the QueuedTasks used in this class completely thread safe in case someone decides to delete lots of variables
Member Leviathan::NetworkCache::RemoveVariable (const std::string &name)
send remove message to clients
Member Leviathan::NetworkClientInterface::DisconnectFromServer (const std::string &reason, bool connectiontimedout=false)
Add a check to not close the connection if it is used by RemoteConsole
Member Leviathan::NetworkMasterServerInterface::CloseDown () override
Actually call this, maybe make this an event listener
Class Leviathan::NetworkResponse
Re-implement limiting string lengths in messages
Member Leviathan::NetworkServerInterface::_HandleServerJoinRequest (std::shared_ptr< NetworkRequest > request, Connection &connection)

Check connection security status

Add basic connection checking and master server authentication check

Member Leviathan::NetworkServerInterface::CloseDown () override
Actually call this, maybe make this an event listener
Member Leviathan::NetworkServerInterface::TickIt () override
Inactive players should be kicked to make DOS:in harder (even shorter limit should be for players that are not currently in any GameWorld)
Member Leviathan::NonOwningScriptCallback::Run (ScriptRunningSetup &setup, Args &&... args)
It might be possible to just keep this locked while calling the method instead of increasing and decrementing the reference count
Member Leviathan::ObjectFile::AddObject (std::shared_ptr< ObjectFileObject > obj)
Disallow adding templates with this function
Member Leviathan::ObjectFile::FindTemplateDefinition (const std::string &name) const
Allow template overloading with different number of parameters
Member Leviathan::ObjectFile::GetObjectWithType (const std::string &typestr) const
Add a function which returns all that matched the type
Member Leviathan::ObjectFile::IsObjectNameInUse (const std::string &name) const
Check template names
Class Leviathan::ObjectFileTemplateDefinition

Potentially allow changing the definition to update instantiations

Make this more robust and nice and reduce the bloat in the implementation

Member Leviathan::ObjectFileTemplateDefinition::CreateInstanceFromThis (const ObjectFileTemplateInstance &instanceargs, LErrorReporter *reporterror=nullptr)

Refactor this function to be smaller

Allow objects to use the special defined values in the ObjectFileProcessor

Class Leviathan::ObjectLoader
Allow objects to be created that will be sent to clients only after the caller has had the chance to create constraints etc.
Class Leviathan::ObjectPool< ElementType, KeyType, AutoCleanupObjects >
Should this class use the ordered_malloc family of methods to allow better use of memory blocks (but is slightly slower for a large number of allocations)
Member Leviathan::ObjectPool< ElementType, KeyType, AutoCleanupObjects >::ObjectPool ()
Figure out the optimal value for the Elements constructor (initial size)
Class Leviathan::ObjectPoolTracked< ElementType, KeyType, AutoCleanupObjects >
Created and destroyed vectors could use swap with last and remove the last to remove more effectively
Member Leviathan::ObjectPoolTracked< ElementType, KeyType, AutoCleanupObjects >::RemoveFromAdded (KeyType id)
Check if this gives better performance than noticing missing elements during node construction
Member Leviathan::ObjectsComponentStates< StateT >::Append (StateT *newstate, StateHolder< StateT > &stateowner)
It is probably more efficient to use a swap algorithm for ading new states instead of this
Member Leviathan::ObjectsComponentStates< StateT >::GetMatchingOrNewer (int ticknumber) const
How can the caller of this method detect when a state has been missed and should instead (maybe) wait a bit? Or should we just skip missed states and start interpolating from the later state
Member Leviathan::PhysicalWorld::ChangeBodyShape (const PhysicsBody::pointer &body, const PhysicsShape::pointer &shape)
Find out if it is required to remove and add the body back to the world (and if that can be done in a physics callback)
Class Leviathan::Physics
Global Newton lock
Member Leviathan::Physics::ApplyForceInfo::Callback
Allow deleting this force from the callback
Member Leviathan::Physics::CreatePhysicsBody (PhysicalWorld *world, const PhysicsShape::pointer &shape, float mass, int physicsmaterialid=-1)
This should be changed so that the Physics constructor would create the physics body
Member Leviathan::Physics::Data::world
Remove if this is still unneeded
Member Leviathan::PhysicsBody::ApplyMaterial (PhysicalMaterial &material)
Add in the properties that make sense as there currently is none
Member Leviathan::PhysicsBody::SetPhysicalMaterialID (int id)
There needs to be a physical world helper for actually applying the new properties
Class Leviathan::PhysicsMaterialManager
file loading function
Class Leviathan::PhysicsPositionProvider
This should have a property for the object deriving from this to be able to tell that it has destructed
Member Leviathan::PhysMaterialDataPair::SetCollidable (bool collidable)
Remove this
Class Leviathan::Position
Initial position states should not be generated or initially sent data shouldn't have the state instead the first state would be guaranteed to be sent after it
Class Leviathan::ProceduralSoundData
Move all the other classes from this file to SoundInternalTypes.h
Member Leviathan::ReceivedSystem::Run (GameWorld &world, std::unordered_map< ObjectID, Received *> &index)
This is now unused
Class Leviathan::ReferenceCounted
Make sure that all functions using intrusive pointers use the MakeIntrusive function
Member Leviathan::ReferenceCounted::GetRefCount () const
Make sure that the right memory order is used
Member Leviathan::RenderingPositionSystem::CreateNodes (const std::vector< std::tuple< RenderNode *, ObjectID >> &firstdata, const std::vector< std::tuple< Position *, ObjectID >> &seconddata, const ComponentHolder< RenderNode > &firstholder, const ComponentHolder< Position > &secondholder)
This should probably not be templated
Member Leviathan::RenderNode
Hidden as serialized data
Class Leviathan::RepeatCountedTask
Merge common parts from this and RepeatCountedDelayedTask
Member Leviathan::RequestCommandExecution
Implement if(Command.length() > MAX_SERVERCOMMAND_LENGTH)
Class Leviathan::ResourceFolderListener
Use only one inotify instance on linux
Class Leviathan::ResourceRefreshHandler
Combine listeners with the same file into a single thing
Member Leviathan::ResourceRefreshHandler::ListenForFileChanges (const std::vector< const std::string *> &filestowatch, std::function< void(const std::string &, ResourceFolderListener &)> notifyfunction, int &createdid)
Allow watching for files in subfolders
Member Leviathan::ResourceRefreshHandler::StopListeningForFileChanges (int idoflistener)
Implement this
Member Leviathan::RunTaskQueuerThread (ThreadingManager *manager)
Improve performance
Class Leviathan::ScriptComponentHolder
Allow defining if release should be called on the script object. and then calling it now only the object is dereferenced so that it probably gets garbage collected soon
Member Leviathan::ScriptComponentHolder::GetIndex () const
Check can we somehow return all the keys and the objects to avoid having to call Find from scripts after this
Class Leviathan::ScriptComponentState
This isn't implemented
Member Leviathan::ScriptExecutor::_GetContextForExecution ()
Allow recursive calls
Member Leviathan::ScriptExecutor::GetScriptModuleByFunction (asIScriptFunction *func, bool reporterror)
When module is null find the module by AngelScript module pointer (set the userdata pointer on the module to point to the ScriptModule object) for faster finding
Member Leviathan::ScriptExecutor::RunReleaseRefOnObject (void *obj, int objid)
This is actually a method in the angelscript engine, so use that, but this is a good example how to run any behaviour
Member Leviathan::ScriptExecutor::RunScript (asIScriptFunction *func, std::shared_ptr< ScriptModule > module, ScriptRunningSetup &parameters, Args &&... args)
Wrap context in an object that automatically returns it in case of expections (_HandleEndedScriptExecution can throw)
Member Leviathan::ScriptExecutor::RunScript (const std::shared_ptr< ScriptModule > &module, ScriptRunningSetup &parameters, Args &&... args)

Allow recursive calls and more context reuse. Also wrap context in an object that automatically returns it in case of expections (_HandleEndedScriptExecution can throw)

Also make all the script module using functions automatically get it if they need for error reporting

Member Leviathan::ScriptExecutor::RunScriptMethod (ScriptRunningSetup &parameters, asIScriptFunction *func, void *obj, Args &&... args)
Merge common parts with RunScript
Class Leviathan::ScriptSafeVariableBlock

Unify multiple values containing things and naming

This whole thing should be made again and the types should be integrated to a single VariableBlock class that has a void* and an angelscript type

Class Leviathan::ScriptScript
Remove this and replace with direct access to ScriptModule
Member Leviathan::Security
Implemented packet breaking for this type
Class Leviathan::Sendable
The world needs to clean ActiveConnection objects from all Sendables related to a closed connection
Class Leviathan::Sendable::ActiveConnection
Make sure that CheckReceivedPackages is called for entities that have stopped moving ages ago to free up memory
Class Leviathan::SendableSystem
Change this to take distance into account don't send as many updates to clients far away
Member Leviathan::SendableSystem::HandleNode (ObjectID id, Sendable &obj, GameWorld &world)
Something should be done with the required state allocation in this method
Member Leviathan::SentNetworkThing::GetStatus ()
Make sure this cannot deadlock
Class Leviathan::StateHolder< StateT >
The GameWorld needs to notify this when ObjectID is deleted
Class Leviathan::StringOperations

Get rid of ElementType and just use ints for everything and hope that it is large enough

Drop wstring support

Member Leviathan::StringOperations::ToUpperCase (const StringTypeN &data)
Make this work with any unicode characters
Class Leviathan::SyncedResource
Possibly do a global static class that will automatically register all when single StartSync is called
Member Leviathan::SyncedResource::SyncedResource (const std::string &uniquename)
Actually check if the name is actually unique
Member Leviathan::SyncedResource::UpdateOurNetworkValue (Lock &guard)
Proper locking
Class Leviathan::SyncedVariables


Add function to be able to check if sync completed successfully

Member Leviathan::SyncedVariables::ValueNamesUpdated
Potentially use a map here
Class Leviathan::System< UsedCachedComponentCollection >
It would bemore efficient to directly create nodes as entities are created instead of running CreateCachedComponentCollections (implemented in subclasses of this)
Member Leviathan::SystemCachedComponentCollectionStorage< UsedCachedComponentCollectionT >::TupleCachedComponentCollectionHelper (ObjectPool< std::tuple< FirstType &, SecondType &>, ObjectID > &CachedComponentCollections, const std::vector< std::tuple< FirstType *, ObjectID >> &firstdata, const std::vector< std::tuple< SecondType *, ObjectID >> &seconddata, const ComponentHolder< FirstType > &firstholder, const ComponentHolder< SecondType > &secondholder)
Also figure out if "CachedComponentCollections.Find(id) != nullptr" should be before _TupleHelperGetIfComponentExists
Member Leviathan::ThreadingManager::Release ()
Do something about unfinished tasks here
Member Leviathan::ThreadSafeObjectPool< ElementType, KeyType, AutoCleanupObjects >::RemoveFromAdded (Lock &guard, KeyType id)
Check if this gives better performance than noticing missing elements during node construction
Member Leviathan::ThrowIfMatrixIsNotOrthogonal (const Ogre::Matrix4 &matrix, float tol=1.0e-4f)
Fix this. This doesn't work because I used Float3 here instead of Float4 as that doesn't have Cross or Dot and this seems to claim that not even an identity matrix is orthogonal
Member Leviathan::VariableBlock::ConvertAndReturnVariable () const
Throw an exception if unallowed
Class Leviathan::Window

Implement global lock for input handling

This should be handled through shared_ptr

Member Leviathan::Window::_StartGatherInput ()

Move to KeyMapping.cpp

Fix mouse capture

Member Leviathan::Window::InjectMouseWheel (const SDL_Event &event)
allow configuring if mouse wheel is considered a key (for Gameplay input mode)
Member Leviathan::WireData::FormatResponseBytesTracked (const NetworkResponse &response, uint32_t messagenumber, uint32_t localpacketid, const NetworkAckField *acks, sf::Packet &bytesreceiver)
This has a lot of duplicated code with FormatResponseBytes
Page NamedVars
This needs redoing
Member Pong::PongGame::OnPlayerStatsUpdated (PlayerList *list) override
Implement this
Member Pong::PongServer::RunAITestMatch ()
Add a score limit and a way to go back to default state afterwards
Make this work
Page Support of event types in scripts
Remove this CEGUI mention and add new GUI click stuff
Actually implement callbacks to ThreadingManager for Engine to call this and make this work