18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-21 06:14:58 +01:00
Files
maszyna/simulation/simulation.h
pol102 c9c390017a feat(editor): area fill: Enter finishes an area, Esc drops the outline, a list of filled areas to change later (#241)
* feat(editor): fill_store, the filled areas kept in the scenery as //$f lines

* feat(editor): fill_store: reading and writing the filled areas

* build: editorFillStore.cpp

* feat(scene): //$f lines of the filled areas kept with the layer files

* feat(editor): area fill: the members of the list of filled areas

* lang(pl): area fill list

* feat(editor): area fill: Enter finishes an area, Esc drops the outline, filled areas listed to be changed later

* fix(editor): the filled areas kept as //$w lines, //$f being the fitted tracks of the profile tool

* fix(editor): a changed area keeps its own rotation and its layer; its models go to the layer of the area, on an undo as on a refill

Change + Enter took the rotation of the Functions panel instead of the area's own:
the area keeps it now, unless the rotation of the panel is changed while the area
is picked up.

The models of an area were made in the active layer, the area record stayed in its
own: on an undo of a change or a removal, with another layer active, they were
saved apart. create_model() takes the layer to put the model in (none: the active
one, as before), and the models of an area go to the layer of the area (the active
one if that's gone). The active layer isn't switched for it: Layers.active() also
shows and unlocks the layer it's given.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DDcMn1Q7wdYkbxDUWscNHZ

* chore(editor): the seeded generator of the area fill marked as not security (Sonar cpp:S2245)

The fill must repeat from its seed (the same area filled again gets the
same objects), so a cryptographic generator is not wanted there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DDcMn1Q7wdYkbxDUWscNHZ

* ci(windows): build lua51.dll for the unit tests

(cherry picked from commit b3e6e02779)

* fix(editor): the filled areas kept under //$u, as //$w is the mark of the shared grade lines on master

After the review of jerrrrycho: on master //$w is the mark of the shared grade lines (scenelayers.cpp,
editormodegradeline.cpp), and both stores save through Layers.mark(Layer, Mark, Lines), which replaces the
lines of the mark. Once master reached this branch, a layer with a grade line and a filled area would have
kept only the lines of whichever store saved last; before that, a master build reads the lines of the areas
as grade lines it doesn't know.

The area fill takes //$u, free on master, on feat/gl46-migration and in the letters of the starters
(n d f i l a), and the same letter the ficzery2 builds the testers have already save the areas under, so
their sceneries keep their areas. A scenery saved by a build of this PR before this commit has its areas
under //$w: they are no longer read as areas; saved again, the editor keeps those lines as lines it doesn't
know.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QRgQ1K1Qu7TCsa74zsNURd

---------

Co-authored-by: miloszunio <miloszunio@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Hirek193 <polomarket73@gmail.com>
2026-11-20 03:56:13 +01:00

120 lines
4.2 KiB
C++

/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "simulation/simulationstateserializer.h"
#include "utilities/Classes.h"
#include "world/Event.h"
#include "vehicle/Train.h"
#include "rendering/particles.h"
#ifdef WITH_LUA
#include "scripting/lua.h"
#endif
namespace simulation {
class state_manager {
public:
// methods
void
init_scripting_interface();
// legacy method, calculates changes in simulation state over specified time
void
update( double Deltatime, int Iterationcount );
void
update_clocks();
void
update_scripting_interface();
// process input commands
void
process_commands();
// create model from node string
TAnimModel *
create_model(const std::string &src, const std::string &name, const glm::dvec3 &position, scene::layer_handle Layer = null_handle);
// places the vehicles, given as their node statements, as a trainset on the path. returns: the vehicles made
std::vector<TDynamicObject *>
insert_trainset(std::string const &Name, TTrack *Path, double const Offset, std::string const &Vehicles, bool const Reversed = false);
// create eventlauncher from node string
TEventLauncher *
create_eventlauncher(const std::string &src, const std::string &name, const glm::dvec3 &position);
// creates model instances defined by an include directive placed in the scenery editor
std::pair<int, int>
preview_include(std::string const &Directive, scene::layer_context const &Context, scene::layer_handle Layer, scene::instance_handle Instance);
// replaces models shown for specified include with the ones defined by its current directive. Retired: receives
// the replaced models made by the editor. they're out of the scene already, but the renderer can still hold on
// to them for a few frames; pass them to Instances.purge() afterwards
std::pair<int, int>
rebuild_include(scene::instance_handle Instance, std::vector<TAnimModel *> &Retired);
// delete TAnimModel instance
void
delete_model(TAnimModel *model);
// gives TAnimModel instance another name; empty text leaves it without one. returns: false if another instance uses the name
bool
rename_model(TAnimModel *model, std::string const &name);
// delete TEventLauncher instance
void
delete_eventlauncher(TEventLauncher *launcher);
// starts deserialization from specified file, returns context pointer on success, throws otherwise
std::shared_ptr<deserializer_state>
deserialize_begin(std::string const &Scenariofile);
// continues deserialization for given context, amount limited by time, returns true if needs to be called again
bool
deserialize_continue(std::shared_ptr<deserializer_state> state);
// stores class data in specified file, in legacy (text) format
void
export_as_text( std::string const &Scenariofile ) const;
private:
// members
state_serializer m_serializer;
struct {
std::shared_ptr<TMemCell> weather, time, date;
// the weather report last written to __simulation.metar, to tell when something else changed it
std::string metar;
} m_scriptinginterface;
};
// passes specified sound to all vehicles within range as a radio message broadcasted on specified channel
void radio_message( sound_source *Message, int const Channel );
extern state_manager State;
extern event_manager Events;
extern memory_table Memory;
extern path_table Paths;
extern road_table Roads;
extern sweep_table Sweeps;
extern junction_table Junctions;
extern roadpoint_table Roadpoints;
extern traction_table Traction;
extern powergridsource_table Powergrid;
extern instance_table Instances;
extern vehicle_table Vehicles;
extern train_table Trains;
extern light_array Lights;
extern sound_table Sounds;
extern particle_manager Particles;
#ifdef WITH_LUA
extern lua Lua;
#endif
extern scene::basic_region *Region;
extern TTrain *Train;
extern uint16_t prev_train_id;
extern bool is_ready;
struct deserializer_state;
} // simulation
//---------------------------------------------------------------------------